[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature Request: rawset return value from __newindex
- From: Daurnimator <quae@...>
- Date: Thu, 20 Oct 2011 12:40:23 +1100
On 20 October 2011 11:16, Patrick Donnelly <batrick@batbytes.com> wrote:
> Consider proxy tables. You never actually add anything to the proxy
> table. All indexes and sets are redirected. e.g.
>
> t = {}
> proxy = {}
> setmetatable(proxy, {__index = t, __newindex = function(_,k,v) t[k] = v end})
>
> [I think you can actually just set __newindex to t, but this should
> work regardless.]
>
> --
> - Patrick Donnelly
>
>
In that case, your example still works: not returning anything results
in returning a nil; this will then set a nil in a table: which does
nothing
ALso, you can't set __newindex to a table: that only works with
__index (Though it would be a nice improvemet if there is no
performance loss)