structs are now lvalues - what is with "auto ref"?

jerro a at a.com
Sun Dec 30 05:42:33 PST 2012


> I'd love to see this fixed as well, but I can't change reality, 
> and I have lots
> of other stuff that I need to do (much of which is 
> Phobos-related) and not
> enough time to do it, so I'm not going to spend the time 
> figuring out enough
> about the compiler to implement it myself. And the reality of 
> the matter is
> that even if someone implemented it right now, it's unlikely 
> that it would end
> up in the next release of the compiler, because it's now in 
> beta. The chances
> aren't necessarily zero, but they're pretty low, and since no 
> one shows any
> signs of implementing it right now AFAIK, that pretty much puts 
> the chances at
> zero.

I've played with this a bit today. The code is at 
https://github.com/jerro/dmd/tree/auto-ref. I know next to 
nothing about DMD, so it could be all kinds of wrong, but it does 
at least seem to work.

What do you think should happen in this case:

void foo(auto ref int a){}
void foo(int a){}
...
foo(1);

should this be an error, or should the second overload be called? 
And what about this:

void foo(auto ref int a){}
void foo(ref int a){}

For this to work, the name mangling for auto ref should be 
different than for ref, but I'm not sure there's value in making 
it work.


More information about the Digitalmars-d-learn mailing list