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

ZombineDev via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 11 06:56:01 PST 2015


On Friday, 11 December 2015 at 14:25:45 UTC, Timon Gehr wrote:
> 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).

Yeah, I forgot to add that it can refer to symbols. Using this 
featue, you can implement a pass by name function (in addition to 
pass by value and pass by reference / address).


More information about the Digitalmars-d mailing list