[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Windows console
- From: Nick.Trout@...
- Date: Wed, 24 Jun 1998 10:01:27 +0000
>
>You have raised an interesting point there as well. Lua is designed as an
>embedded language but the way it outputs text is not very convenient for
>systems which can't trap the standard streams. ie. Windows (unless I'm
>missing something).
Lua is designed as an embedded language for ANSI C programs.
Any compiler that claims to support ANSI C *must* provide some
implementation
the standard streams.
Think C on the Mac does this.
I don't know about Windows. Can someone please enlighten me here?
>You have to go through the Lua code and alter every
>printf, fprintf etc. to redirect the output to your buffer.
There are just a couple of such places:
print in lbuiltin.c
the standard error handler in ldo.c
Plus, you can always set your own error handler.
>What about having a function: int lua_SendToOutput(FILE* stream, const
>char *pBuffer, ...);
I guess you can always write your own printf and fprintf and override the
compiler's implementation.
---------------------------------------------------------------------------
-----
Does anyone know how to redirect the standard output streams into memory in
Windows (sorry I'm not an expert on this area of Windows)? You can use
freopen to redirect the standard streams into a file and then possibly
redirect this into a buffer but this seems like a bodge.
Surely if you trying to write ANSI code, you DONT want to be doing things
like redefining standard libraries (ie. printf)!
I still think it would be preferrable if Lua had text output wrapper. Don't
get me wrong, I think you have done a superb job with Lua. As embedded
languages go it is definitely the best I have found yet. It just seems like
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
modifying (apart from a few value number casts to avoid warnings!). If it
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!
Nick