lua-users home
lua-l archive

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

On Mon, Mar 2, 2020 at 2:22 AM Sean Conner wrote:
                local a,a = 1,2 print(a)
        and it's the second declaration that survives (Lua 5.3).  Weirder,
        in the following:
                a,a = 1,2 print(a)
        it's the first declaration that survives. 

The order in a multiple assignment in Lua is UB,
so your program's behavior must not depend on the order.

3) v = t[a][b][c][d][e]
        v ends up nil.  Which index is nil?

The whole point of the proposal is to not bother user with such details.
An _expression_ should "just work".

  I contend that typos happen, bugs exist 

Yes, the _expression_ t[a][b][c][d][e] will not detect a mistake.
But returned nil would probably raise an error on the next line of your code
(if the logic of your program expects non-nil value).

The point is that we need "silent" version of t[a][b][c][d][e] much more frequently
than "error-raising" version.
We can easily convert "silent" version to "error-raising" by applying assign() to the result.
But the reverse conversion is significantly harder.