lua-users home
lua-l archive

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


>     This isn't related with local keyword only, see:
> 
> x,y = 10,20 -- x(10), y(20) :1 line
> z, w = 20 -- z(20), w(nil) :2 line
> x = 10, y -- x(10), y(nil) :3 line
> 
> In the above code, reading the second line we think w will be 20, but
> really
> z is 20. This isn't an error, but it's hard to switch out of normal
"view"
> ;-). This is the "adjusting" feature of lua, isn't it?

You just have to get used to the idea of multiple assignment and the
syntax provided. Once you've made the mistake a couple of times you
won't do it again. It's the same in other languages, e.g. Python, but
noticeably Python does give an error is you have mismatched assignments.
I suppose the graceful handling of mismatched assignments is an
extension of the way variable function arguments are dealt with. 

For count(LHS) < count(RHS) an error does seem to make sense, and for
count(LHS) >= count(RHS) leave it alone.

Nick