I agree: the values have to be constant at compilation time.Background information: The rationale is that the compiler must be able to verify that all case label values are disjunct, there is no overlap.
[…] Does anyone know how can I change codeYou must “translate”, i.e. displace and scale your values to ranges you know at compile-time, something like:to calculate based on what I type (what values) into edit? (categorize based on what I type edits)[…]
2000..3000: N_res.text:='low'
unfortunately it does not work really with InRange (sure i don't use it well)?Yes, use of InRange implies use of if then else construct instead of case.
[…] So why is fpc not going that way to enlargen sets?Delhpi compatibility.
[…]Well, “fun fact”: At one point something like 1337 in -42..5040 (https://wiki.freepascal.org/User_Changes_2.6.0#.3COrdinal.3E_in_.3CSet_type.3E_is_now_forbidden) was possible.
[…] class Operator TMyRangeType.in(A:Integer;B:TMyRangeType):Boolean;Inline; […]
[…] So why is fpc not going that way to enlargen sets?Delhpi compatibility.
I know that "Delphi compatibility" is always the alibi for nearly every bug or restriction.Well, then it isn’t so much about creating conflicts but there just were “more important” Delphi-compatibility-related things, so those were attended first, before creating something new, you know.
But this time not.
If you build a superset for the range of a set it does not disturb Delphi compatitbility, […]
The 256 element set restriction is a relict of Turbo Pascal and was already old fashioned in these days.I absolutely agree with you. The compiler and RTL (https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_2_0/rtl/inc/genset.inc?view=markup#l15) do contain code for what’s called “Varset”. I understand the current default set implementations are “small set” and “normal set” in FPC terms (https://wiki.freepascal.org/Type_information#set_definition_(TSetDef)).
I don’t know how to enable/use those “varset”. In revision 8515 (https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=8515) Jonas wrote there were still problems, though.
I know that "Delphi compatibility" is always the alibi for nearly every bug or restriction.Well, then it isn’t so much about creating conflicts but there just were “more important” Delphi-compatibility-related things, so those were attended first, before creating something new, you know.
But this time not.
If you build a superset for the range of a set it does not disturb Delphi compatitbility, […]
The 256 element set restriction is a relict of Turbo Pascal and was already old fashioned in these days.I absolutely agree with you. The compiler and RTL (https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_2_0/rtl/inc/genset.inc?view=markup#l15) do contain code for what’s called “Varset”. I understand the current default set implementations are “small set” and “normal set” in FPC terms (https://wiki.freepascal.org/Type_information#set_definition_(TSetDef)).
I don’t know how to enable/use those “varset”. In revision 8515 (https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=8515) Jonas wrote there were still problems, though.
The problem is less Delphi-compatibility, but more size. If you have a set of 1024 elements you need 1024 bits aka 128 Byte aka an array of 32 UInt32. Of course one might argue that in today's time that is nothing, but one shouldn't scoff at that either.
That said I'd guess that we'll increase the limit of sets in one of the next major releases.
@winni, I've already seen you regret about the lack of sets in FPC more than 256 elements several times.
Are you only interested in the built-in set, or is a home-made one suitable?
This set(TGSet (https://github.com/avk959/LGenerics/blob/23b33120e76cbb2c5bf9c18c5d41cc0156b37139/lgenerics/lgutils.pas#L1009)) is part of a fairly large unit within the package, but the good news is that this unit is self-sufficient and the TGSet itself depends on the minimum set of functionality of this unit. Thus, it is easy to make TGSet self-contained and the license does not prevent you from doing this.
Hi Roland
I attached small app.