FAQ
My worry is not the usefulness, it's separating the signal from the noise.
err and ok, for instance, are frequently shadowed deliberately, and in any
sizable project it would probably be hard to sift through all of the
"warning: err shadowed" to find the real issues. You could use a
name-based heuristic to exclude err and ok, similar to the assumptions made
about Printf in go vet, but then I think we'd get complaints about how
someone accidentally shadowed err and wasn't warned about it, even with vet.

On Fri, Feb 22, 2013 at 3:51 PM, Johann Höchtl wrote:

On 21.02.2013 16:43, Patrick Mylund Nielsen wrote:

I agree about gc, but I think it would be reasonable to have 'go vet' warn
about this by default. If you ARE shadowing intentionally, a warning from
vet isn't going to alarm you.

I would be very much in favor of such a flag. It would be helpful (even
if only for beginners) and won't harm otherwise.

On Thu, Feb 21, 2013 at 4:37 PM, Ian Lance Taylor wrote:

On Thu, Feb 21, 2013 at 7:22 AM, George Shammas <georgyo@gmail.com>
wrote:
The flag should be the other way around.

Most people who complain about shadowing are either new to the language or
don't understand block scoping. So why make it a flag to enable the check
when they wouldn't even to understand what the flag does without
researching
it.
Any such flag effectively creates a new dialect of the language. For
example, there are multiple dialects of C, including the language
described by the standard and the language accepted by GCC with the
-Wall -Werror options. I think we would want very compelling reasons
to split Go into multiple dialects at this point.

I agree that short declarations using :=, redeclarations using :=,
block scoping, and for and if statements introducing a new block scope
can in combination lead to situations that can be confusing. There
may be some way to improve matters. But I don't think that adding a
compiler flag is it.

Ian

--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Related Discussions

People

Translate

site design / logo © 2021 Grokbase