lua-users home
lua-l archive

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


> 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

Would that be exactly equivalent to this?

  function __newindex(t,k,v)
    if condition then
      rawset(t,k,nv)
    elseif othercondition then
      rawset(t,nk,v)
    elseif anothercondition then
      rawset(t,nk,nv)
    else
      rawset(t,k,v)
    end
  end

What is the gain?

-- Roberto