lua-users home
lua-l archive

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


Is this a program you're working on yourself, or are you extending someone else's work?

Some people like to do this little trick:

local io = {
  write = write,
}

Do you have access to _G, or getfenv?  Try comparing io to _G.io or getfenv(0).io.

-Rob

On Dec 31, 2010, at 3:17 PM, Hans van der Meer wrote:

> In Lua I can write
>   io.stderr:write(msg)
> and get the msg on the stderr output stream.
> Therefore I conclude io.stderr is in the globally accessible space.
> 
> In an alternative, special output module I want to duplicate this behaviour. Although I have managed to get working:
>    io.write(stderr, msg)
> The equivalent of the above io.stderr:write(msg) does not know stderr: "attempt to index field 'stderr' (a nil value)"
> 
> I have in earnest sought in the documentations as well as in the sources, but could not find how to accomplish this. Is there someone who will enlighten me and point in the right direction?
> 
> Thanks in advance,
> Hans van der Meer
> 
>