lua-users home
lua-l archive

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



On Sun, Jul 14, 2013 at 4:55 PM, John Hind <john.hind@zen.co.uk> wrote:
local x = 0b1001_0001 - support of underscores here is particularly useful
to break long bitmaps into fields - they're just for documentation and get
ignored).

This is cool; there are two ways to get this with existing Lua. One, define a memoized conversion function 'b' and then you can write b'1001_0001' to represent binary patterns. Two, hook into current environment with __newindex and convert globals looking like b1001_0001. (Implementation left as exercise)