lua-users home
lua-l archive

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

Hi all,

The writeup (and links) are here:

The four big changes in this release are:
(1) Can use a simplified string macro definition style (suggested by
Thomas Lauer and coming from his work on Idle) which can be used in
the same source file as its uses:

__def 'dump(x) print(_STR(x).." = "..tostring(x))'

hello = 42
hello = 42

(2) Macro names can be general tokens, e.g. here is a implementation
of lhf's short lambda syntax:


macro.define ('\\', {'args','body';handle_parms = true},
    'function(args) return body end',
    function(ls) -- grab the lambda
        -- these guys return _arrays_ of token-lists. We use '' as the delim
        -- so commas don't split the results
        local args = macro.grab_parameters('(','')[1]
        local body = macro.grab_parameters(')','')[1]
        return args,body

So \x(x+1), \x,y(x+y), \x\y(x+y) etc work as expected.

(3) Macros can install lexical scanners that look for end-of-block.

So handler(function(...) ... end) can be written like handler begin ... end

(which is LeafStorm's BeginEndProposal (see wiki page))

macro.define ('begin',nil,function()
    macro.set_end_scanner 'end)'
    return '(function(...)'

(4) the __line builtin macro can be used to set the line number
information that the parser sees:

__line 30
(this code starts on line 30)
__line 100

Unfortunately, not possible to set the _filename_ that the parser
sees; this would require a patch to the token filter patch.

Not for everybody, but can be very useful in custom debugging and
testing code. And can make writing DSLs easier.

For the curious who are living on Windows without a compiler, here is
a token-patched version of Lua 5.1.4  (only 72K !!)

(not LfW compatible, compiled with mingw)

Remember as always, that a token-patched Lua compiler can write
compatible bytecode.

steve d.