Accessing types by context
Anonymouse via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 29 00:10:12 PDT 2016
On Wednesday, 29 June 2016 at 05:06:08 UTC, Hiemlick Hiemlicker
wrote:
> On Wednesday, 29 June 2016 at 03:50:35 UTC, Carl Vogel wrote:
>> On Wednesday, 29 June 2016 at 03:11:52 UTC, Hiemlick
[...]
>> Doesn't the with statement solve your problem here?
>>
>> with (myEnum) {
>> test(A);
>> test(B);
>> test(C);
>> }
>
> Not really it's, only half the way there. Why not extend the
> language the extra step?
I'm not sure I understand how it doesn't. Inside the with scope
you could refer to myEnum members by their (unqualified) names
alone. Isn't this the behaviour you're asking for?
As a pet peeve of mine, it's unfortunate that with: cannot be
used as attributes can, to last until the end of the current
scope without adding a new one.
> void foo()
> {
> with(myEnum): // doesn't work
>
> test(A);
> test(B);
> test(C);
> }
More information about the Digitalmars-d
mailing list