FAQ

On Wed, Feb 20, 2013 at 5:43 PM, Norbert Roos wrote:
On 02/19/2013 08:20 AM, Johann Höchtl wrote:

[...] The variable "found" is hidden. This is clearly a mistake yet get's
unspotted by the current compiler. [...]

I would propose another radical solution for this: Simply that shadowing
variables is not allowed.
Good bye block scoping.
When you are about to shadow a variable, use a
different variable name.

I mean this really serious; compared to C, Go made some useful restrictions,
limiting the programmer's freedom in some way, like the mandatory use of { }
in all if's anf for's. Forbidding variable shadowing could be one more such
thing. I could live with that restriction very well.
I cannot recall a single one of the imperative mainstream languages
which doesn't have block scoping. Not an argument, of course. Just
makes one wonder why it is like that.

-j

--
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

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase