lua-users home
lua-l archive

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


Quoth David Manura <dm.lua@math2.org>, on 2010-09-18 16:41:29 -0400:
> >  ==> _PP.expr_if((( a ) and _PP.expr_then( b ))
> >                  or (( c ) and _PP.expr_then( d ))
> >                  or (_PP.expr_then( e )) or nil)
> 
> The run-time overhead that that adds can be avoided.  It is possible
> to mechanically translate expression ifs into their statement format.

Of course it is, but (a) the inline closure approach breaks the use of
the vararg token inside the expressions unless you do complicated
things, and (b) hoisting the statement outside requires effort more on
the order of doing full compilation stuff (and then preserving the
line numbers becomes a nightmare and you might as well start patching
Lua or writing a whole extra language on top of the runtime).

Right now I'm using a Ragel-based mishmash which has a few pushdown
automaton elements in it but is otherwise mostly a fancy token filter.
Upgrading that into a full parser would be a lot of extra work.

Patching Lua, while popular, is something I want to avoid requiring
because I expect to run in environments where Lua is a shared library
and where carrying around patched copies of third-party code is seen
as very bad, among other reasons.

I imagine that's what you meant when you said "it's not the simplest
thing to do".  :-)

   ---> Drake Wilson