Eigenpoll : D wish list : L-Value return To make user-defined types (and properties of classes) first class citizens with respect to builtin types (and data members of classes), one needs to be able to return an L-value.
This wish list item would go together with the other wish list items that deal with improved support for value-types: "stack classes"/"struct inheritance, ctors"/"auto members".
A property of a class cannot have the ++ operator acted upon (because a function cannot return an L-value). The code
doesn't work, because there is no way in D for a user defined property to return a reference to an int.
User defined value-types (primitives like vectors, matrices, colors, quaternions, planes, lines, points, etc..) cannot made to behave exactly like builtin types, because some operations need to return an L-Value:
(+a) = 3;
The above is possible for an int, but not for a user defined struct/class.
Report this item for cleanup