[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua strictlessness
- From: Robert Virding <robert.virding@...>
- Date: Thu, 29 Aug 2013 15:53:10 +0200 (CEST)
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.
----- Original Message -----
> From: "Mark Hamburg" <email@example.com>
> To: "Lua mailing list" <firstname.lastname@example.org>
> Cc: "Lua mailing list" <email@example.com>
> 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()