lua-users home
lua-l archive

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


From: Luiz Henrique de Figueiredo
> If assignment were an expression, what would be an interpretation
> for multiple assignment?

An array-table of all the values? A vararg ... thingy?

FWIW, Ruby treats assignments as expressions, and supports parallel
assignment (which is what I assume you mean by multiple assignment).
Internally it splats the array as part of multiple assignment:

irb(main):001:0> r = (a,b = 1,2)
=> [1, 2]
irb(main):002:0> c,d = r
=> [1, 2]
irb(main):003:0> c
=> 1
irb(main):004:0> d
=> 2
irb(main):005:0> r.class
=> Array

I'm not suggesting that Lua needs to treat assignment as expressions
(though I personally like that), just pointing out how another language
handles it as food for thought.