[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Assignment as operator
- From: David Given <dg@...>
- Date: Mon, 11 Aug 2008 14:18:54 +0100
On Mon, 2008-08-11 at 08:02 -0500, Paul C. Anagnostopoulos wrote:
[...]
> Once you made assignment an operator, you would have to define it as
> evaluating to its right operand.
C doesn't; 6.5.16 constraint #2:
> An assignment expression
> has the value of the left operand after the assignment, but
> is not an lvalue.
Because Lua allows arbitrary behaviour on assignment, things are very
much more complicated than in C. Is the result of the assignment the
modified value of the thing being assigned to? What happens if it
doesn't have a value? While it's not a particularly complex question ---
the simplest answer is to simply leave it up to the metamethod to return
whatever value it sees fit --- it's one that's sufficiently fraught with
subtleties that IMO such a thing be left out of the language unless it
becomes absolutely necessary to add it.
--
David Given
dg@cowlark.com