lua-users home
lua-l archive

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

>From Tue Jul 20 02:32:38 1999
>From: Dave Bollinger <>

>   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 

Note the use of upvalues to access the 'old' write while still redefining it.