[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Function source
- From: David Jeske <jeske@...>
- Date: Sun, 21 Dec 1997 10:01:54 -0800
On Sun, Dec 21, 1997 at 11:02:55AM -0200, Alan Watson wrote:
> I have been thinking about writing a replacement for lua_getobjname
> that scans tables recursively as well as globals. I want to use this
> to print better function names in error messages.
I do the same thing to print object names. I only let my search go three
levels down from "global" though. I just assume that after that it's just
more trouble than it's worth to find. You also have to be carefull about
circular links if you are going to do it recursively.
> It just occured to me that a nicer alternative would be very simple
> with the kind of function method that has been discussed. What I would
> do is extract the function name of a function as it is compiled, and
> keep a table of these names; lua_getobjname becomes, for functions at
> least, a simple table access.
Why not just change the parser/VM to store the declared function name and
argument names. Of course anonymous functions won't have names. However, I
can see this data being relevant in many situations and it shouldn't be to
hard to do. In fact, it's sort of on the road to this whole "storing
source for functions" thing.
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net