[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Feature Request: rawset return value from __newindex
- From: Daurnimator <quae@...>
- Date: Thu, 20 Oct 2011 11:12:39 +1100
A small feature request to distract you all from the noise on the list recently:
I often find myself writing code like
mt.__newindex = function ( t , k , v )
v = dosomethingwithv ( v )
Could we make it so the return value of __newindex is then set as the
value in t?
It will be backwards compatible, as the majority of code out there
don't return anything from __newindex operations.
- One less line of code
- __newindex operations can now do a tail call; `function (t,k,v)
return dosomethingwithv(v) end;
- I assume it can be optimised quite well in the actual
implementation, as the key has already been hashed; and we know its
not already in the table.