lua-users home
lua-l archive

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


> That's a point I never found a good reason for: why do you
> require parentheses for expressions like the ones from the OP?
> 
> Is it just to allow parentheses to start a statement?!?  Just
> drop that (imho mis-)feature.  It creates ambiguities (just
> look at that "ambigious syntax" error that requires function
> calls to conform to a strange whitespace rule), makes regular
> expressions have to use superfluous parenthesis and makes it
> hard to detect statement beginnings.
> 
> A simple rule: a statement begins with either a reserved word
> (for, while, etc) or an identifier. Point.
> 
> [...]
> 
> And, if I remember correctly, such a change even simplifies the
> parser.

I agree that it can be done, but I did not understand how it would
simplify the parser. The current problem is that we use a single
non-terminal 'functioncall' for both expressions and statements. To
allow "x":foo() as an expression but not as a statement, we would
have to duplicate that non-terminal.


> [Btw, I can't remember that I ever actually used this construct...]

I frequently write statements like '(print or myprint)(x)'.

-- Roberto