lua-users home
lua-l archive

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


I think the first thing to decide is whether creating a new local variable is a bug or a feature. Currently it is a feature so at best the compiler could warn that this is happening as it can create strange errors. If it should be a bug then you need to decide whether to allow multiple declarations of the SAME local variable or not. It is definitely not a difficult thing for the compiler to check however you decide to do it, in fact having separate variables can actually be more difficult.

Coming with an argument that you don't need a check, all you need is enforcing discipline, is IMAO a very bad option as it hits the people who can least defend themselves, inexperienced users. They are the ones who are least likely to know about it at all (the manual doesn't shout out loud about it) and the least likely to understand what is going wrong. Checking it in tools is ok, sort of, but the inexperienced user is the one who is least likely to know about the tools.

So I think at least the compiler should at least warn by default, with an option to keep quiet. Preferably disallow it.

Robert

----- Original Message -----
> From: "Mark Hamburg" <mhamburg.ml@gmail.com>
> To: "Lua mailing list" <lua-l@lists.lua.org>
> Cc: "Lua mailing list" <lua-l@lists.lua.org>
> Sent: Tuesday, 27 August, 2013 11:10:15 PM
> Subject: Re: Lua strictlessness
> 
> Any warning for shadowing would almost certainly want to make an exception
> for '_' since it is frequently used for don't care variables including in
> constructs like:
> 
> local _, _, third = returnThree()
> 
> Mark
> 
> 
>