[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: print() vs. write()
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 20 Jul 1999 07:54:09 -0300 (EST)
>From lua-l@tecgraf.puc-rio.br Tue Jul 20 02:32:38 1999
>From: Dave Bollinger <DBollinger@compuserve.com>
> Just curious why print() has an implicit call to tostring() for
>unhandled types while write() does not. So that print(t) is not equivalent
>to write(_STDOUT,t.."\n"). It's adequately documented, and it's not a
>problem, I was just wondering.
No reason. print is supposed to be used only for debugging.
You can redefine write to do automatic conversions.
Something like:
function write(...)
foreachi(arg, function (i,v) %write(tostring(v)) end
end
Note the use of upvalues to access the 'old' write while still redefining it.
--lhf