lua-users home
lua-l archive

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


I think he means specifically in the constructor and the compiler. I could see a small case for this but it would have to be a switch. I am guessing that there is code out there that uses this 'feature'. Generated code specifically.

Leigh

----- Original Message ----- From: "Hakki Dogusan" <dogusanh@tr.net>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Tuesday, March 13, 2007 10:30 AM
Subject: Re: Why duplicate keys in table constructor isn't an error?


Hi,

Ivko Stanilov yazmış:
I've often made this mistake in my programs when copying/pasting table
elements, or just by oversight:

 local table = { key = "value1", ..., key = "value2" }

Shouldn't the compiler be able to detect this case and report a syntax
error? I know that you could possibly have expressions with side
effects in the place of "value1", but nevertheless I can't envision
a scenario in which having the same constants keys in the same table
constructor is intentional. This is a 100% error in the code and I
think it should be reported as such.

Regards,
Ivko






If you think it like following it makes sense, IMHO:

local table = {}
table.key = "value1"
...
...
table.key = "value2"



--
Regards,
Hakki Dogusan