lua-users home
lua-l archive

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

On Sat, Nov 27, 2010 at 2:35 PM, Luis Carvalho <> wrote:
> Which brings me to my next point: should we be discussing something more
> general beforehand, such as statements as expressions or a macro facility?
> Most of this discussion on shorter forms would become moot if, for example,
> the token filter was made official in Lua 6.0...

In particular, lexical macros are more restricted than actual syntax
patches, due to the limited look-ahead.  So \x(expr) and lambda
(x)(expr) are both straightforward, because it's easy to find out
where the expression begins and ends.  |x| expr is probably
impossible, since the token filter has to second-guess the parser to
discover where the expression ended.

There are several objections to the token patch approach.  It's valid
for people to worry about any extra overhead if they never have any
intention of knowingly using it ;)  In my experiments I could hardly
measure the compile-time overhead, but more tests are needed.

The other objection is a generalization of the objections to
short-form functions: an overenthusiastic customizer could generate
truly bizarre syntax and it could lead to gratuitous changes because
it's cool (or something).  But if people use syntax extensions in
their project, then the market shall decide;  weird shit will not get
traction, and we can depend on Darwinian Selection ;)

There is another line of objection which is important here. Looking at
the syntax diagram of Lua, fitting neatly and clearly into a page, I
feel great admiration for such economy and elegance.  Adding a
technique which fell out of favor in the early 1980s might feel
jarring. However, compile-time metaprogramming is more fashionable,
and it would be most excellent to have metalua-like syntax extension
in the core language.

steve d.