alias to fully qualified enum in scope where enum is expected

Timothee Cour via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 6 09:23:32 PDT 2014


Thanks, I know with statement could be used but I was hoping for a solution
not involving adding syntax to call site.

void fun(with(A){A a}, int b){...} //conceptually like this
void test(){
 int a1=1;
 fun(A.a1, a1); // would work
 fun(a1, a1);    // would work
}


On Wed, Aug 6, 2014 at 8:22 AM, Meta via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> On Wednesday, 6 August 2014 at 07:23:32 UTC, Rikki Cattermole wrote:
>
>> The magic of with statements!
>>
>> enum A {
>>         a1,
>>         a2
>> }
>>
>> void func(A a){}
>> void main(){
>>         func(A.a1);
>>         with(A) {
>>                 func(a1);
>>         }
>> }
>>
>
> And if you want to be *really* concise:
>
> with (A) fun(a1);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140806/fda51525/attachment.html>


More information about the Digitalmars-d-learn mailing list