lua-users home
lua-l archive

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


Kenneth Forsbäck wrote:
Does anyone have any snippet of lua code, modified lua, or something else that would allow me to use C-esque syntax, lua is starting to hurt my eyes.

Note! I am not going to use metalua, already made that mistake once.

Kenneth

I actually tried working on a mod of Lua to do this sort of thing. But
it turns out that, when you go to work it out, all sorts of ambiguity
issues arise with curly braces being used for table construction on the
one hand and block nesting on the other. (Just think about how much
lookahead would be required to distinguish between { a = b } and { a =
b; }. I don't know how most implementations of JavaScript do this, but
its parser must be doing something weird...)

C itself gets around this by not allowing array literals to be first
class values. They only work in initial variable declarations, at least
in ISO C89, and even the compilers that do support first-class array
literals as an extension require some extra noise (a leading cast in
GCC) to help the parser along. But in a language like Lua, where table
literals have to be first-class values, the ambiguity isn't acceptable.

Patrick