lua-users home
lua-l archive

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

Tim Hill <> wrote:

>> On Jan 28, 2018, at 1:24 PM, Dirk Laurie <> wrote:
>> 2. In a for statement, allow extra conditons before the 'do'.
>> 2a.
>> for _,item in ipairs(list) if type(item)=='table' do
>> ...
>> end
>> equivalent to
>> for _,item in ipairs(list) do if type(item)=='table' then
>> ...
>> end end
> -1 to all of #2
> It won’t change runtime performance so far as I can see, and it appears to
> complicate the syntax for no gain other than not typing one or two extra
> keywords (“then” and “end”).

The syntax is completely optional though, if you didn't want to use it then
you wouldn't have to. Actually, adding this extension would be fairly easy
to do and I don't think it would even expand the parser by very much at all.

Sometimes a bit of syntactical sugar is nice if it helps people represent
the intent of their code better. Of course, that is always going to be a 
subjective thing... one person's trash is another person's treasure. ;)