lua-users home
lua-l archive

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


On Thu, Jul 14, 2011 at 2:51 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> So you can check whether the source is "=stdin":
>        print(debug.getinfo(1).source)

LuaJIT does not set this, but it's easy to get around it.

e.g.

-- P.lua
require 'pl'
local _print = print
function print(...)
 if debug.getinfo(2).source == '=[C]' then pretty.dump(...)
 else _print(...)
 end
end

and then define LUA_INIT to be require'P'

> = debug.getinfo(1)
{
  linedefined = -1,
  currentline = -1,
  lastlinedefined = -1,
  func = "function: 0x003722a0",
  source = "=[C]",
  nups = 0,
  what = "C",
  namewhat = "",
  short_src = "[C]"
}
> print(debug.getinfo(1))
table: 0x00388190

steve d.