lua-users home
lua-l archive

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


Dear Lua users,

I face a situation I do not understand.

I wrote a simple file "essai.lua" containing :

--
function essai1()
  print(debug.getinfo(1,"n").name)
end

essai1()
--

When I do

$ lua essai.lua
essai1

This is logical to me.

Now, if I start lua and *copy and paste* the same code as in "essai.lua", I have

$ lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
function essai1()
  print(debug.getinfo(1,"n").name)
end

essai1()
nil

I do not understand why in one case, I obtain "essai1" (expected) and in the second case, I obtain nil ? I know that functions in lua do not have a fixed name and getinfo(1,"n") is in charge to find an appropriate one. But why are the results so different in a so simple example. Is it a bug ?

Philippe