On Tue, 22 Dec 2009 08:41:11 -0500, Steven Schveighoffer
<[email protected]> wrote:
On Tue, 22 Dec 2009 08:30:33 -0500, Andrei Alexandrescu
<[email protected]> wrote:
Kagamin wrote:
Andrei Alexandrescu Wrote:
I think, possible solution is to disallow assign operations on the
return value: =, +=, *=, ~=, ++ etc, but read operations should be
allowed and functions should be callable by their symbolical names.
Won't help. Consider:
a.b.c.d.e.f = g;
If anywhere on the path an rvalue is created, the code is useless
busywork.
In contrast with the original example this is not a bug.
I think it is to the extent (a) it does nothing (b) the syntactic
equivalent code involving fields does something. It's an egregious
breakage of consistency because properties were meant to be
generalizations of fields in the first place.
What if a.b returns a Rebindable!(const(T)) rvalue, and the rest are
lvalues?
I just realized in my efforts to use a real phobos-supported wrapper type,
I doomed my own argument :)
The point is, wrapper types shouldn't have second-class citizenship as
rvalues to pointers and references. There's got to be a way to identify
types as being lvalues even though the compiler doesn't see it that way.
If you can accomplish that, then I have no problem disallowing setting
members of true rvalues.
-Steve