lua-users home
lua-l archive

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

On Jan 29, 2018, at 8:50 AM, Paige DePol <> wrote:

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'.

for _,item in ipairs(list) if type(item)=='table' do

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. ;)


But aren’t you assuming that one person is doing all the coding? In any large project you might inherit code from different people (including those who have long gone), and they may have decided the “optional” syntax was nice, even though you had never come across it before. And where do you draw the line on all those nice little “tweaky” enhancements? A dozen? Two dozen? Welcome to PL/1, or Java, or C++, or Ruby, or …

To my mind, any change to Lua should be able to answer “yes” to at least one of these questions (necessary but not sufficient justification):

-- Does it improve the runtime performance for real-world code (not benchmarks)?
-- Does it increase the clarity of the language?
-- Does it increase the functionality of the language?

I don’t think Dirk’s suggestion #2 does that.