lua-users home
lua-l archive

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


Joseph Stewart wrote:

> If I added base#number support to Lua, would there be interest in some
> kind of string.format extension for base output as well? I know I'd use
> it. I'm not sure how to extend the sprintf style output specifier in a
> sane way, though.
> %b# ... where '#' is from 2 to 36

To me conversion from a base to a string is a minor thing. The only
bases I would find useful are decimal, hexadecimal, and binary. Your
idea about the arbitrary base using base#number sounds a lot like the
Ada way. It is very convenient, especially when the use '_' characters
is allowed within the number portion. It makes bit fields easy to delineate.

But if I had my way, I'd rather see hexadecimal escape sequences in
strings, especially now that 0xXX is supported through the C99 strtoul()
call. That would make my life a tad easier. Of course there are
workarounds for everything (including a patch to the language to support
it).

And even before hexadecimal escape sequences, my first and second
choices for Lua improvements are (1) an integer type and (2) bitwise
operators for integers or even for the existing Lua number type,
whatever it happens to be. Either could be implemented without the other.

What is driving my desire for an integer type is my embedded target
where I have software floating point only. My scripts run very slowly to
do what should be simple things. I don't want to give up the ability to
use floating point (there are still plenty of uses for it), but I'd like
to be able to avoid the overhead when necessary.

But that's just my particular corner of an obscure part of the Lua universe.

Some other idle musings...

I like the idea of setting aside a bunch of operators that have no
meaning in the current instance of Lua. This would require an
enumeration of all the possible operators in the VM. The language could
define any undefined operator (such as, say, '^^') to return its left
argument. Or something similar. This may require certain limitations on
new operators (binary versus unary) and precedence rules might also be
necessary. But I like the idea of being able to replace any operator via
the metatable.

Also, rather than using '__mul' in the metatable, use the operator
string '*' itself.

Alas, I need to get so many other things taken care of before I can
dedicate more time to hacking the Lua VM.

Doug

-- 
--__-__-____------_--_-_-_-___-___-____-_--_-___--____
Doug Rogers - ICI - V:703.893.2007x220 www.innocon.com
-_-_--_------____-_-_-___-_--___-_-___-_-_---_--_-__-_