lua-users home
lua-l archive

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


On Mon, Mar 31, 2014 at 10:14 AM, Petite Abeille
<petite.abeille@gmail.com> wrote:
>
> On Mar 31, 2014, at 2:57 AM, Thiago L. <fakedme@gmail.com> wrote:
>
>> I mean I can't set __metatable to a function so…
>
> Eh?
>
> local aFunction = function() end
> debug.setmetatable( aFunction, { __tostring = function() return 'm e t a  f u n c t i o n' end } )
> print( aFunction )
>

That's setting the metatable OF a function.

What doesn't work is:

debug.setmetatable( aFunction, function(key) return --[[magic]] end )

I myself am still trying to figure out the exact USE case, but I at
least know what's being asked for.

/s/ Adam