I always assumed it was because without braces (yes they're called braces,
not curlies... which gives me a whole different image *shudder*) it's
clearly wrong.  You've probably made a mistake in this case so the compiler
is being helpful.  With braces, you're probably going to add some more code
later so it would be annoying if you got a compiler error for something
that isn't technically wrong.

David

"If we can hit that bullseye, the rest of the dominoes
 will fall like a house of cards... checkmate!"
 -Zapp Brannigan, Futurama


On 4 June 2013 15:27, mike smith <[email protected]> wrote:

>
>
> On Tue, Jun 4, 2013 at 3:22 PM, David Burstin <[email protected]>wrote:
>
>>
>> On 4 June 2013 15:08, mike smith <[email protected]> wrote:
>>
>>> It isn't the flow control constructs doing it, it's the scoping.
>>
>>
>> Agreed.
>>
>> It is quite clear when there is 'explicit' scoping (curly brackets), but
>> there is also 'implied' scoping (eg a single line after an if). Why can't a
>> useless variable be declared after an if without braces, but is ok if we
>> wrap that single line in a pair of curlies?
>>
>> It's easier (for maintainers) to explicitly scope it with unnecessary
> curlies than rely on implicit.  Our internal coding rules mandate stuff
> like that :)  Which didn't really answer that question, either.
>
>
>
>

Reply via email to