[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: getting function name
- From: Sean Conner <sean@...>
- Date: Sun, 16 Nov 2014 14:01:05 -0500
It was thus said that the Great jseb once stated:
> Hello,
>
> I'm trying to write a helper function for getting function name with
> function pointer.
> «AH! Recursion with _ENV!» i thought.
> Like all simple and good idea, it was not so simple and not so good.
>
> For an unknown reason, it will work with functions directly stored
> in _ENV, but not with subtables.
>
> get_fx_name(get_fx_name) -- works
> get_fx_name(math.cos) -- thrash stack
>
> Do you have any idea why ? Thank you.
Take a look at package.loaded. Not only does it contain a reference to
package, but it also contains a reference to _G.
-spc (Recusion: see recursion)