[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Proposal] _GETNAME upvalue
- From: Marcus Mason <m4gicks@...>
- Date: Mon, 21 Jun 2021 12:45:01 +0100
You can already produce this effect in lua. This is not a complete recreation because real extension methods (a la C#) should override methods no matter where they come from. Lua doesn't have methods so it doesn't make sense.
Personally this seems a bit pointless because you can just use __index on a proxy table to achieve this effect since there's no methods and symbol resolution in lua.
I personally don't see the use of it.
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
This allows doing t:insert(foo) on any table t.