[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_getinfo(L,"n",&ar) doesn't use upvals to guess function name?
- From: Tim Gogolin <tgogolin@...>
- Date: Fri, 19 Mar 2004 13:25:56 -0600
Thanks for the info; my workaround seems to be doing just fine at
finding the additional function names.
I appreciate Rici's comments about things with names being explicitly
named, but this really is not part of my data model; its just an
attempt to get a better stack trace when things go wrong, so I don't
think its worth requiring code style changes at all function definition
On Mar 19, 2004, at 11:57 AM, Roberto Ierusalimschy wrote:
Is my understanding correct that lua_getinfo(L,"n",&ar) does not look
at the previous stack frame's upvalues when guessing a "name" for the
If so, is there any reason why not?
No, besides some extra complexity.
My workaround for this will be to query the calling 'ar' myself and
search the named upvals (if getinfo fails to find the name through the
normal mechanism). Is there any reason why this is a bad idea?
Quite the opposite. We have plans for moving this whole "name
stuff outside the Lua core into a library (at least the part that can
be implemented with the debug API). In that way, the algorithm could be
smarter and easier to change (e.g., it could look inside libraries to
find names like "math.sin", could look for upvalues, etc.)