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

Jonathan M Davis jmdavisProg at gmx.com
Fri Dec 28 17:14:38 PST 2012


On Friday, December 28, 2012 23:29:38 Namespace wrote:
> Spontaneous question: why was the behavior altered from lvalue to
> rvalue if there is still no replacement with "auto ref" and so a
> lot of code becomes invalid?
> I know of course that the change was necessary, but as long as
> there is no fix I don't understand such ruthless change.
> It meant no offense, I'm just curious.

Because the code was invalid to begin with. It was a bug that it was ever 
allowed. Not fixing it would just encourage people to continue writing 
incorrect code and thus break even more code later. And it's not like the 
functions that currently work with ref or const ref are going to later when 
the auto ref situation is sorted out, since it's almost certain that that will 
be solved with auto ref and not by changing anything with ref or const ref.

Also, there's the cost in confusion caused by allowing foo(S(5)) but not 
foo(bar()). So, in some ways, allowing the broken behavior actually causes 
more problems than fixing it does.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list