lua-users home
lua-l archive

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


On Wednesday 04 August 2004 13:46, Andreas Falkenhahn wrote:
[...]
> is it possible for a Lua function (in C) to find out the names of the
> variables that were passed? e.g.
>
> myfunc(a, b, c)
>
> I can get the values of the variables using luaL_checknumber()
> but is it also possible to get the names of the variables that
> were passed? i.e. the strings "a", "b" and "c"

I doubt it; remember that local variables don't have names once they've been 
passed, and in fact there might not even be any variables. The user may have 
done:

	myfunc(1, 2, 3)

or

	myfunc()

...instead.

If you really need to do this kind of thing, I suspect that your only option 
is to use the debug library, look at your caller's stack frame, and then use 
undocumented internal nastiness to examine the byte code directly.

I suspect that the real answer to your question is 'You don't want to do 
that.' What are you trying to do?

-- 
+- David Given --McQ-+ "I don't like the thought of her hearing what I'm
|  dg@cowlark.com    | thinking." "*No-one* likes the thought of hearing
| (dg@tao-group.com) | what you're thinking." --- Firefly, _Objects in
+- www.cowlark.com --+ Space_