why are Assign Expressions r-values?
BCS
ao at pathlink.com
Fri Apr 27 23:07:10 PDT 2007
Reply to Manfred,
> BCS wrote
>
>> however the expression could be used as an l-value
>>
> Because one can overload the assignment,
Even so the semantics would work, do the assignment as normal (function call
or otherwise) and then take the symbol in the LHS and use it as the "value"
of the expression.
> your question has a
> generalization:
>
> given a function with exactly one "ref" or "out" parameter, why is
> this function an r-value?
>
> example:
> int f( int i, ref int j){ }
> now the semantics of an assignment like
>
> f( a, f( b, c))= d;
>
> should be clear.
>
> -manfred
>
In that case there is no named symbol to use for the outer call. In the assign
case (even when opAssign is overloaded) there is always a LHS symbol that
is an l-value that can be used.
More information about the Digitalmars-d-learn
mailing list