Few things

Scott David Daniels Scott.Daniels at Acm.Org
Fri Dec 3 19:14:32 CET 2004


Josiah Carlson wrote:
> An option if you want to get all of the base representations available
> is a prefix notation that is similar to what already exists.  I'm not
> advocating it (because I also think its crap), but the following fixes
> the problems with your postfix notation, and is explicit about bases.
> 0<base>_<number>
> like:
> 016_feff
> 02_10010010101
> 010_9329765872
> 08_767
> 
> The above syntax is:
> 1. unambiguous
> 2. readable from left-to-right
I built an interpreted language where based numbers were of the form:
    <base-1>..<number>
It has 1 & 2, can often be snagged from standard lexers, and keeps _
available for group-separator (for things like 1_000_000_000).
The nice thing is that it is unambiguous no matter what base you
read in.  It also worked for floating point values, but we were never
happy with how the exponent should be done.
     f..feff == 1..1111_1110_1111_1111
             == 1..1_111_111_011_111_111 == 7..77377
     1..10010010101
     9..9329765872
     7..767
Takes a bit to associate 9 with base ten, but lexing the number is
duck soup.  Note I am not advocating this syntax any more than Josiah
is advocating his.  I just find alternate representations interesting.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list