[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal] _GETNAME upvalue
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Mon, 21 Jun 2021 07:48:05 -0300
On 2021-06-21 4:33 a.m., Egor Skriptunoff wrote:
> Why might we want to redefine methods of an object locally (inside the
> current module) instead of globally (everywhere the object appears)?
> Please provide real-life examples
>
local _GETNAME = function(o, k)
if type(o) == "table" and k == "insert" then return table.insert end
return o[k]
end
This allows doing t:insert(foo) on any table t.