lua-users home
lua-l archive

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




On 2022-04-08 20:34, Luiz Henrique de Figueiredo wrote:
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).
I don't think i understand what you're saying. are you talking about a limitation of patching the source code? That's not really my question, I'm asking why this isn't already a feature in lua, seeing as so many other languages support it. Patching the source code on my end, especially in a backward-incompatible way as you suggest here, would mostly defeat the entire purpose of compiling to lua (portablity).