lua-users home
lua-l archive

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


> if not, is there some reason lua doesn't include this?

One reason is that Lua keeps track of line numbers in bytecode but not
of file names: each function has only one source.
In particular, what do you expect from the code below?

% cat foo.lua
print"1"
a()
$ "@hello" 89
print"2"
error"boo"

In one interpretation, the error message is
./lua: hello:2: attempt to call a nil value (global 'a')
not
./lua: foo:2: attempt to call a nil value (global 'a')

If you can live with that limitation, see the attached code (which
works in Lua 5.4 and most probably earlier versions).

Attachment: proxy.c
Description: Binary data