lua-users home
lua-l archive

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

Op Tue, 23 Jul 2019 16:10:09 +0200 schreef Pedro Tammela

In Python 3.8 there will be a new feature introducing Assignment
Expressions[1]. One of the reasons for such feature is to improve code
readability, among other things.

Would assignment expressions improve Lua code readability?


Maybe I missed the momentum of the discussion but I would like to see something similar in Lua.
It encourages to use RAII, and reduces the scope of the variable.

We already have in Lua some form of assignment expression in... for loops.
No one has been complaining about that.

Another example is C++17 that allows you to do something like:

if( auto foo = get_foo() ; == 42 )
  foo.baz( 1337 );

-- Jasper