How is `auto` and not `alias` appropriate for alias sequences?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 11 06:25:45 PST 2015


On 12/11/2015 03:12 PM, ZombineDev wrote:
>
> alias can refer to types, templates, template argument lists and
> compile-time expressions. It can't refer to run-time variables.

Yes it can.

void main(){
     int x=0;
     alias y=x;
     y=2;
     assert(x==2)
}

It cannot refer to a field or method of a runtime variable though (it 
still compiles, but the 'this' reference is just thrown away).


More information about the Digitalmars-d mailing list