[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Metaprogramming
- From: steve donovan <steve.j.donovan@...>
- Date: Sat, 5 Jul 2014 12:41:19 +0200
On Fri, Jul 4, 2014 at 9:16 PM, Carlos Pita <email@example.com> wrote:
> standard function calling syntax & semantics plus some lambda shortcut
> like | ... | could go a long way in the direction of implementing
> custom control structures or language constructs, without requiring
> macro support at all.
I appreciate this point as well; although I went to trouble to get
LuaMacro right, I no longer believe that ad-hoc syntax extension is
appropriate for code shared with other people. I'm also a fan of
the |...| syntax that's enabled with GSL Shell - the author's
rationale is that it makes interactive experimentation less verbose.
But there doesn't seem much chance of it making into mainstream Lua.
Another approach is to use a different but consistent notation for Lua
programs, for example Moonscript - this has a lightweight function
syntax. Together with the very low precedence of the call operator
this makes it an excellent candidate for implementing DSLs. It
compiles to straightforward Lua and so access to the Lua ecosystem
(and LuaJIT) is straightforward.
For instance, defining a function is straightforward:
sqr = (x) -> x^2
Table sorting (note the low call operator precedence)
table.sort t, (x,y) -> x.name > y.name
You could argue that this isn't Lua any more, but then neither would
be any customized dialect... one sacrifices the syntactical simplicity
of Lua for a gain in expressiveness. 
 it also complicates tool support
 but the syntax is consistent and fixed, so (e.g.) latest version
of ZeroBrane Studio can debug Moonscript as well.