How can this code
{$scopedenums on}
type
Bar = set of (A, B, C);
refer to A, B, C?Mailing lists / fpc-pascal / 2018-04
Inline scoped enums
6 messages · 3 people · –
- MMattias Gaertner 3
- РРоман 2
- AAlexander Grotewohl 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Show quoted text 5 lines
How can this code
{$scopedenums on}
type
Bar = set of (A, B, C);
refer to A, B, C?
Bar.A
Mattias
Show quoted text 7 lines
> How can this code
> {$scopedenums on}
> type
> Bar = set of (A, B, C);
> refer to A, B, C?
Bar.A
Actually Bar.A won't work, notice the "set of".
Same problem with var x: (a, b, c).
I wonder could they make such code to not compile at all...
indeed. there are other type declarations where 'set of' is valid, so maybe it inadvertently piggybacks on those
to correct the code.. something like:
{$scopedenums on}
type
bar = (a, b, c);
var
foo: set of bar;
begin
foo:=[bar.a, bar.c];
if bar.a in foo then
writeln('yay obscure pascal features! :)');
end.Роман wrote 13 lines
>> How can this code
>> {$scopedenums on}
>> type
>> Bar = set of (A, B, C);
>> refer to A, B, C?
> Bar.A
>
Actually Bar.A won't work, notice the "set of".
Same problem with var x: (a, b, c).
I wonder could they make such code to not compile at all...
_______________________________________________
fpc-pascal maillist -
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
On Fri, 6 Apr 2018 21:38:59 +0300 Bar.A Mattias
Show quoted text 10 lines
On Fri, 6 Apr 2018 21:38:59 +0300
Роман via fpc-pascal wrote:
> How can this code
> {$scopedenums on}
> type
> Bar = set of (A, B, C);
> refer to A, B, C?
Bar.A
I correct myself:
Bar.A is wrong.
A is right.
It's a bug in FPC.
Mattias
Show quoted text 19 lines
On Sat, 7 Apr 2018 08:52:43 +0200
Mattias Gaertner wrote:
> On Fri, 6 Apr 2018 21:38:59 +0300
> Роман via fpc-pascal wrote:
>
> > How can this code
> > {$scopedenums on}
> > type
> > Bar = set of (A, B, C);
> > refer to A, B, C?
>
> Bar.A
I correct myself:
Bar.A is wrong.
A is right.
It's a bug in FPC.
It's also buggy in Delphi. As a nested type in a class you cannot access A, neither with scopedenums of or on:
type
TC = class
public
type TBar = set of (A, B, C);
end;Neither A, nor TBar.A, nor TC.TBar.A works in Delphi 10.2.
Mattias
Mattias
