lua-users home
lua-l archive

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


> For a long time I used $LUA_INIT to redefine print() to a pretty
> printer* for Lua values (primarily tables). Unfortunately this can break
> Lua programs that use print() for output instead of io.write() and
> assume it works exactly the same as print() from the base library. There
> is a very easy way to fix this: Change the second rule above to call a
> function that is dedicated to pretty printing of values in the
> interactive prompt, e.g. prettyprint(), dump(), something like that (I
> don't care about the name as long as it's different from print() :-).

The function you are asking for already exists, but its name *is*
"print". The other one, the one that programs should be using for
output, is called "io.write". If those programs are broken, fix them,
not the language.

-- Roberto