FAQ

On Wed, Feb 20, 2013 at 5:07 AM, Johann Höchtl wrote:
On 02/19/2013 10:03 PM, Jan Mercl wrote:

This is how block scoping must work for it to be useful. Imagine for
example code getting moved around. There's no reason for the compiler to
say anything about it.
Ok, but when you remove the block, code like this is very likely to be
erroneous:

var i int

if i != 0 {
} else {
}

Of course, Go promises to be well defined but it's still likely to make no
sense as i get's never explicitly assigned to
the behavior of your example really is well defined, and it might be the
programmer's intention,
or not, but in general (like the other thread about giving error for const
if conditions), the compiler
is impossible to know the real intent at this stage (and when they do,
maybe we don't even need to write it down).

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