[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Excessive expressions in assignment (was: Garbage Collector)
- From: "Leandro Candido" <enclle@...>
- Date: Mon, 15 Dec 2003 03:36:41 -0200
Hello Edgar,
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?
But your question persist.
The God's Peace,
Leandro.
----- Original Message -----
From: "Edgar Toernig" <froese@gmx.de>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Monday, December 15, 2003 12:37 AM
Subject: Re: Excessive expressions in assignment (was: Garbage Collector)
> Reuben Thomas wrote:
> >
> > > local x = 10, y
> >
> > This is incorrect syntax. You meant
> >
> > local x, y = 10
>
> The problem is that it *is* correct syntax but
> most probably not what one wants. If one comes
> from C/C++ it's easy to make this error and Lua
> accepts it silently.
>
> Therefore the question: Should Lua issue an error
> for this condition, fewer names on the left hand
> side than expressions on the right hand side?
> It normally makes no sense to explicitly supply
> excessive expressions.
>
> If yes, what about regular assignment?
>
> Ciao, ET.
>