lua-users home
lua-l archive

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




On Fri, Sep 14, 2018 at 4:00 PM Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
Ternary (conditional) operator. Using (x and y or z) has become an
idiom, which shows the real demand for such a feature, but the fact that
it breaks when y is false or nil makes for a lot of landmines.

Something like #... to return the number of varargs without needing to
pass them all to another function as in select('#',...).

--
Andrew.

I'm a big proponent of NIL_IN_TABLE because it would give us the ability to mimic "sequences" without holes, but most other things I would like to see are syntactic sugar:
- Safe table navigation
- adding to self using  "+="
- Ternary conditions 
 
I used to be a proponent of case statements, but the flexibility of "if else" and the consistency of a single pattern for checking values is winning me over. I know ternary conditions breaks that consistency, but it could be worth breaking for the ability to write succinct code. 

As a side remark, I've been mucking with C and the intricacies of distributing Lua for so long now, I had almost forgotten what a pleasure it is to *write* Lua. My current distraction/project (a lua minecraft sever controller) has reminded me of the elegance of the language. 

Russ