lua-users home
lua-l archive

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


Lua list <lua@bazar2.conectiva.com.br> writes:
>The Lua core does not use stdio, except for sprintf.

The problem I was thinking of was one that used to occur with CodeWarrior
on classic MacOS. The stdio was supplied as a static library, but this
library was dependent on another library called SIOUX which implemented
the console I/O (no command line on classic MacOS, you see). This meant
that if you wanted to use sprintf - which doesn't really have anything to
do with file or console I/O - then you had to include these libraries in
your project. These libraries then had their own conflicts, warnings and
other issues.

Now, it may be that this kind of thing only EVER occurred on the largely
obsolete classic MacOS using the obselescent CodeWarrior IDE. However, I
think it is true to say that I/O routines and libraries are naturally more
troublesome than most other code due to their dependence on I/O hardware,
windowing/console systems, etc. I have always thought it was a major
design mistake that sprintf was declared in stdio because it places this
very useful non-I/O routine in a library along with potentially
troublesome I/O routines. Usually it is no trouble but it can be a problem
for code designed to be embedded, like Lua.

So, in a perfect world, sprintf would be replaced by an equivalent routine
defined in the Lua source. Ideally, this would be more like the formatted
print statement from C# (ie, it would use something like "Hello {1}"
rather than "Hello %s"). I am no big fan of C#, but this feature is a
slight bonus for internationalisation. It means you can change the
ordering of the substitued strings simply by altering the curly bracketed
numbers in the format string. This is great for re-wording error messages
in (human) languages that use a different word order from English. This
Lua-defined routine might require slightly less memory than sprintf, too,
because it need not handle all the options that sprintf does.

However, I realise that re-writing the sophisticated sprintf routine is a
major undertaking for relatively little gain - I am not expecting it to
appear in Lua anytime soon!

&.


#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by NetIQ MailMarshal.
The Blackpool Sixth Form College.
#####################################################################################