[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Windows console
- From: David Jeske <jeske@...>
- Date: Tue, 23 Jun 1998 11:24:47 -0700
On Tue, Jun 23, 1998 at 01:29:36PM -0300, Luiz Henrique de Figueiredo wrote:
> >From Nick.Trout@psygnosis.co.uk Tue Jun 23 13:18:04 1998
> >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?
Right, but on windows it's basically impossible to get Lua's printf stuff
to redirect into your console without overriding _all_ printf
functionality. I can override the lua internal 'print()' function, but
that isn't everywhere that lua uses printf.
In Lua 2.5 I just changed the internal lua print stuff to use a different
C function (dolua_print) so I could redefine where it goes. However, in
3.1 there are quite a few printf()s in the lua code, so I redirected _all_
printf()s by writing a new version of it. However, I would much prefer if
all lua print stuff went through a feeder api which could easily be mapped
to the standard funtions. For example:
Lua would never use:
Instead it would do something like:
So I could easily trap and redirect these without affecting my programs
output facilities. If someone didn't want to redirect them, it would be
easy enough to provide standard implementations.,
> >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
Even if it's going to remain this way I would prefer it if Lua would
enforce some concept of 'in the box' and 'out of the box'. Namely, put all
the 'absolute' output functions in one file, and make a convention in lua
not to use printf() or fprintf() outside that file.
I agree completely with the original poster that as an embedded language
it isn't necessarily that useful for it to print to stdout.
> I guess you can always write your own printf and fprintf and override the
> compiler's implementation.
Yeah, and I do this, but it redefines _all_ my printf and fprintf usage,
so now I have to go around those functions when I really want to output to
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + firstname.lastname@example.org