[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: bitwise ops -- make them enums! (Re: what's wrong?)
- From: Joseph Stewart <joseph.stewart@...>
- Date: Thu, 9 Feb 2006 10:45:08 -0500
Sorry for replying to myself...
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
Just thinking out loud here... haven't started coding yet.
On 2/9/06, Joseph Stewart <
Boy, I'd like to see something like the base#number format in Lua. There's already base 2-36 support via tonumber(). Would anybody else besides me find this useful? I'll post a
5.0.2 patch if there's enough interest!
On 9/4/05, Chris Pressey <
On Sun, 4 Sep 2005 15:32:00 +0200
Mike Pall <firstname.lastname@example.org> wrote:
> And I really don't want to write things like this anymore:
> local opcode = op == "movzx" and 4023 or 4031
> But rather:
> local opcode = op == "movzx" and 0x0fb7 or 0x0fbf
If you do write a patch for this, may I suggest the following syntax,
borrowed from Erlang (which possibly borrowed it from somewhere else):
local opcode = op == "movzx" and 16#0fb7 or 16#0fbf
simply because it is far more general and orthogonal - if you want octal
constants you can prefix them with 8#, and binary constants with 2#.
There's no need to remember arbitrary conventions for which prefix goes
with which base, and (FWIW!) you can recognize odd bases like 3# or 9#
just as easily.
(Note that I'm not suggesting # as an infix operator - it's a purely
lexical delimiter... a lot like a decimal point, actually.)