[fpc-devel] TShiftState as enum
drdiettrich at compuserve.de
Thu Feb 17 10:34:11 CET 2005
Marco van de Voort wrote:
> > > TShiftState is defined as TShiftState = set of (...);
> > >
> > > How can I iterate through the enums? If not, can we split and add an
> > > enum:
> > >
> > > TShiftStateEnum = (...)
> > > TShiftState = set of TShiftStateEnum;
> > >
> > > ?
> > Of course that is possible. It requires some imagination though (and a feel
> > for obfuscated Pascal)
> The example fails in Delphi 6 btw, but works in FPC :-)
> Delphi does not allow low/high on sets
> (I vote to keep this FPC extension btw)
Can somebody enlighten me, what code exactly fails in D6?
What extension does FPC have, that Delphi doesn't have?
And what "iteration" is desired? I'd use: For Low(x) To High(x)...
Let me add some more notes, regarding Delphi compatibility:
Older Delphi (and TP?) versions implemented sets of subranges (e.g. set
of 510..515) by "stripping" unused bytes in front of the set. The lowest
bit in a set variable always had an ordinal value of 2^n, and above set
would occupy 2 bytes, equaling an set of (504..519). In newer Delphi
versions the lowest bit exactly corresponds to the lowest ordinal value
in the range, the above set only occupies one byte (510..517).
AFAIR D6 introduced "open" enums, with arbitrary (discontinuous...)
values for the members. IMO this only is an attempt to closer reflect C
enums, but sets of such enumerated types are not allowed.
I do not ask for any compatibility in these cases, in detail when the
Delphi implementation differs amongst compiler versions.
More information about the fpc-devel