[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Improvements for creating DSL with Lua
- From: Alexander Gladysh <agladysh@...>
- Date: Sun, 16 Aug 2009 22:06:54 +0400
> Since its origin, Lua is well suited for data oriented DSL.
> But for declarative DSL, the mandatory use of parenthesis for arguments function
> (except in case of a single string or table) is a big limitation.
> As example, consider the 2 following versions of the same code
> (which come from my current work on <http://github.com/fperrad/lua-Coat/>
> and it is not really a DSL
> and David Manura already send me some good suggestions in pure Lua)
> -- "classic" Lua
> class 'Point'
>
> has( 'x', { is = 'rw', isa = 'number', default = 0 } )
> has( 'y', { is = 'rw', isa = 'number', default = 0 } )
I usually use this idiom in my DSLs:
has "x" { is = 'rw', isa = 'number', default = 0 }
has = function(name)
return function(data)
return has_impl(name, data)
end
end
Also, if you have an urge to patch Lua syntax, take look at Metalua:
http://metalua.luaforge.net.
HTH,
Alexander.