lua-users home
lua-l archive

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


>From Nick.Trout@psygnosis.co.uk Wed Jun 24 06:11:39 1998

>Surely if you trying to write ANSI code, you DONT want to be doing things
>like redefining standard libraries (ie. printf)!

Exactly my point.
Any compiler that claims to support ANSI C *must* do something sensible
with printf and the like.
Some will do a bad job. In Windows, I think the nicest thing to do would be
to open a text console, with cut-and-paste and all -- not run the program
in DOS mode. Perhaps, this is an option in the compilers.

>a bit of a cludge to have to go through the Lua source (in each new
>version!) and edit all the printf's as none of the rest of the source needs

Like I said, "all the printf's" are *exactly* 2!
One is for a built-i function "print" (which you don't really need)
and the other is for lua_error, which you can trap.
So, I don't see any reason for changing the code at all!

>modifying (apart from a few value number casts to avoid warnings!).

I'd like to know what these warnings are. We take care to avoid all warnings.

>is to be a truly embedded language then I feel the client should have more
>control over where the output goes.
>ANSI doesn't specify that all output
>must go to the standard streams!

Right. That's why you can set your own error handler.
The rest of the output is in Lua's standard libraries and go explicitly to files.
The sample interpreter lua.c certainly assumes a text console, but I'd expect
that a much better one could be written for Windows. I just don't know how
to do it. C. Terra has written a very nice one for the Mac. There's a link
to it in our site.

To make my point again: The core of Lua does *not* output to stdout.
It can output to stderr in the default error handler.
The built-in function "print" outputs to stdout, but if you call it, you know
this. To output to files, use "write". To output to strings, redefine "write".

--lhf