On Wed, 21 Feb 2018, Ryan Joseph wrote:
I just learned FPC has scoped enums, which is nice, but they lack what you
could call “relative inference” based on the type being passed. In the example
below the parameter “t” is TMyType but passing “A” doesn’t work. Doesn’t the
compiler know the type and can infer “A” is relative to the scoped enum? I
understand there’s a possibility for name conflicts but you could just use the
full name in that case.
Is this a missing feature or do you need to enable it or something?
{$scopedenums on}
type
TMyType = (A, B, C);
{$scopedenums off}
procedure DoThis (t: TMyType);
begin
end;
DoThis(A);
The whole point of scoped enums is to force you to write TMyType.A
everywhere.
So this is "as designed". If you want to be able to write A, don't use
scoped enums.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal