lua-users home
lua-l archive

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



On 4-Feb-07, at 7:55 PM, Miles Bader wrote:

Fabien <fleutot+lua@gmail.com> writes:
I've also experimented with shorted syntaxes for multiple statements instead of single expressions as aboved, but in the end I felt that it wasn't worth it. However, you can still use it (it's "do |foo, bar| stat1; stat2;...statn end" in the currently available version IIRC), or define whatever suits
you.

Hmm, since square-brackets are currently not valid in an
"expression-initial" context in lua, how about just using them as
syntactic sugar for an anonymous function?

That conflicts with [ ] in table syntax; although it's not strictly speaking ambiguous, I don't think, it certainly stops being LL(2), so a recursive descent parser is much more difficult. (The question is at what point you know that a [ indicates a key-value expression, rather than a value.) Also, if you actually wanted to put a [...] block as a key, you'd need to remember to put a space in, to avoid having [[ turn into the start of a long string.