lua-users home
lua-l archive

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


> Well, 'end' is hard to get rid of, but 'then'
> is already totally unneeded by the compiler.  
> It could be made optional by tweaking one line 
> of code, with zero side effects. Same goes for 
> the "do" following "for" and "while" loops, 
> totally unneeded.

I had always just assumed that 'DO' and 'THEN' were necessary because of
some ambiguity regarding parsing the conditional expression prior to it.
But after reading your message, I looked deeper and found that DO and
THEN do indeed seem superfluous.  

Here's a diff off the current version, on lparser.c.  Works for me!
Would be nice if the Lua authors considered making DO and THEN optional.

811c811
<   check(ls, TK_DO);
---
>   optional(ls, TK_DO);
841c841
<   check(ls, TK_DO);
---
>   optional(ls, TK_DO);
908c908
<   check(ls, TK_THEN);
---
>   optional(ls, TK_THEN);