News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
io.write() vs. my_output:write()
Author Message
Junior Member

Posts: 5
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 1
Post: #1
RE: io.write() vs. my_output:write()

I belive print is a special case as the print function is not really suitable for general file writing.

The print function does things to the data that io.write does not.
1. Converts everything to a string
2. Separates multiple arguments with tabs
3. Always appends a newline

This is great when used as a debugging tool using the old method of peppering your script with print statements. It is also useful to inspecting properties of variables, tables, etc.

But it would really mess up when trying to write to a real file.

I suppose you could define a new print function in your script that would you could use instead of io.write.

I am guessing that the system's print function saves the current stdout assignment, then sets to a normal stdout, the screen, and afterwards reassigns the saved stdout.

07-15-2007 11:56 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
io.write() vs. my_output:write() - mikshaw - 07-15-2007, 04:19 AM
RE: io.write() vs. my_output:write() - roberts - 07-15-2007 11:56 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: