lua-users home
lua-l archive

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


On 2018-09-15 10:18, Lorenzo Donati wrote:
On 15/09/2018 02:00, Sean Conner wrote:
It was thus said that the Great Jim once stated:
i would add support for binary and octal integer literals like 0b1001011 or 0o0755 as in Python and Ruby.

octal integer literals are helpful when working with unix (file)
 modes/permissions (which i do frequently).

I would not object to this, but what I would like to add is '_' to literal numbers to aid in comprehension. Some examples:

Yep! This is really something I miss among low-level stuff.

Yip yip yip! ^^

Underscores in number literals kill most of the accidental off-by-(power
of $base) typos.

I implemented (repeatedly :-) some functions that handle that, together with handling binary numbers (answering to Roberto here), but I find them too "hackish", i.e. they work well for my codebase, but other people may use their own variation and interoperability becomes a nightmare.

Problem with those (I use them too…) is that they don't get the compile
time evaluation treatment that plain literals get.  Which means you get
to choose between fast XOR readable, which is always a bad pairing…
(Guess what I'll usually choose… =/)

I think something so basic should be in the bare language. Probably it doesn't even add much weight to the parser. (Not a problem for me now - I'm just wearing my old and dusty professional dev hat :-)

IIRC you don't need to touch the parser at all, just the lexer.

-- nobody