lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Oct 14, 2014, at 4:42 AM, Thiago L. <fakedme@gmail.com> wrote:

> Hi,
> 
> I guess you can claim this is a proposal but I also want feedback on it...
> 
> The idea is new semantics for __newindex so you can use it without rawset():
> 
> function __newindex(t,k,v)
>  if condition then
>    return k,nv
>  elseif othercondition then
>    return nk,v
>  elseif anothercondition then
>    return nk,nv
>  else
>    return k,v
>  end
> end
> 
> Unless your __newindex returns junk, this shouldn't break anything.
> 
> Thanks.
> 

I think the biggest argument against this is that it only applies to tables. What about userdata? Having the added complexity of tables be a special cases doesn’t seem to be warranted by the minor convenience.

—Tim