Why do associative arrays return from opIndexAssign by value?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jun 18 02:27:47 PDT 2013
On Tuesday, June 18, 2013 11:18:33 TommiT wrote:
> On Tuesday, 18 June 2013 at 09:07:31 UTC, deadalnix wrote:
> > Assignation aren't lvalues in general, so that is consistent.
>
> I didn't see that coming. In C++ assignments are pretty
> consistently mutable lvalues. Do you know why this is so in D?
Assignment operators definitely should return lvalues normally. I don't know
why deadalnix would think otherwise. It's pretty much the norm in C++, and I
see no reason for it to be different in D. No, it doesn't work for all types,
but in the general case, it should.
However, given the current state of AAs and the fact that their implementation
pretty much needs to be completely redone, I'm not sure how good an idea it
would be to make this work right now. Maybe it wouldn't be a big deal, and
maybe it would be a very bad idea. It certainly wouldn't hurt to open an
enhancement request though:
http://d.puremagic.com/issues
At minimum, I would think that in the long run, we would want what you're
trying to do to work.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list