Lua Macro Facilities

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua Macro Facilities

Glenn edgar
Hi All

Is there a package in Lua that approximates the Macro capabilities that are lisp or schema.

Thanks

Glenn Edgar


Reply | Threaded
Open this post in threaded view
|

Re: Lua Macro Facilities

Vyacheslav Egorov
try metalua <http://metalua.luaforge.net/>

--
e.v.e



On Wed, Jan 7, 2009 at 10:19 PM, Glenn Edgar <[hidden email]> wrote:
> Hi All
>
> Is there a package in Lua that approximates the Macro capabilities that are
> lisp or schema.
>
> Thanks
>
> Glenn Edgar
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Lua Macro Facilities

Luiz Henrique de Figueiredo
> try metalua <http://metalua.luaforge.net/>

There's also Asko's luaSub and my own bare-bones token filters.

Reply | Threaded
Open this post in threaded view
|

Re: Lua Macro Facilities

Vyacheslav Egorov
lua-users wiki also mentions such projects as:

luaFish <http://lua-users.org/wiki/LuaFish>
LuaMacros <http://lua-users.org/wiki/LuaMacros>

Transitive closure of these articles will reveal several other
projects, I guess.

--
e.v.e



On Wed, Jan 7, 2009 at 10:36 PM, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
>> try metalua <http://metalua.luaforge.net/>
>
> There's also Asko's luaSub and my own bare-bones token filters.
>

Reply | Threaded
Open this post in threaded view
|

Re: Lua Macro Facilities

Asko Kauppi
In reply to this post by Luiz Henrique de Figueiredo

Don't let the "beta" tag at LuaForge scare you. It's beta since I was the only user at time (and I thought it'd be getting some complaints/ changes).

	http://luaforge.net/frs/?group_id=311

It has not gained any, I wonder if it's gotten any users either... :P

24h support & help from this email.

The main difference between MetaLua is that MetaLua builds a syntax tree whereas luaSub does the filtering kind of on a running (token) window. The ways to make syntax mods to the two are obviously completely different. I believe any syntax mod can be made with either one.

-asko



Luiz Henrique de Figueiredo kirjoitti 7.1.2009 kello 18:36:

try metalua <http://metalua.luaforge.net/>

There's also Asko's luaSub and my own bare-bones token filters.


Reply | Threaded
Open this post in threaded view
|

Re: Lua Macro Facilities

Fabien-3
In reply to this post by Glenn edgar
Hi, here's a biased comparison.

Token filter based solutions (luasub and raw token filters) are probably simpler to learn in the initial stages, if you have no significant experience in tree-manipulating macro systems such as Lisp dialects. 

Metalua lets you see your code as concrete syntax or abstract syntax trees, indifferently. It also lets you switch from one view to the other. If you have already use multi-stage metaprogramming languages such as Template Haskell, MetaML or Converge, you'll be immediately at home.

Another key difference is that Metalua handles syntax extensions through a parser combinator library. I would argue that It's more flexible / modular than PEGs: it lets you easily define functors, can be modified dynamically, and lets you (relatively) easily generate proper error messages, when incorrect inputs are entered. However, it might have a slightly steeper learning curve for simple tasks; at least, it looks more intimidating.

This issue is acknowledged and I'm working on it: a DSL to define / extend grammars is under development. An example, a JSON parser, is accessible here (look at the stuff between <<  >>).


Beyond this, the main limitations are:
- macro hygiene is handled in a less than ideal way. I would love to adapt Clojure's brilliant approach to the issue, but it's difficult without breaking Lua compatibility (this is not relevant to other systems, which work at a much lower level)
- installation of version 0.4 is awfully messy, largely because the compiler is partly written in itself and therefore requires a bootstrapping step. A reorganized version is accessible here, although unreleased (click on the download button):


-- Fabien.