why scope(success)?

James Dunne james.jdunne at gmail.com
Thu May 11 07:37:49 PDT 2006


Ben Hinkle wrote:
> "Sean Kelly" <sean at f4.ca> wrote in message 
> news:e3tjf6$1v3n$1 at digitaldaemon.com...
> 
>>James Dunne wrote:
>>
>>>if statements do not create a scope without { }, therefore it should be 
>>>at B.
>>
>>They don't?
>>
>>
>>Sean
> 
> 
> They do. The code
>   if (1)
>     int a = 10;
>   a = 20;
> is illegal. 
> 
> 

Then the implementation according to D's language specs is incorrect. 
Nothing is mentioned about new scopes created by if-statements or 
while-statements.  New scopes are only created from block { } statements 
when inside a function body.  Scope is mentioned (in passing) for the 
for-statement; the initializer is noted as a special case.  Did I miss a 
blanket statement somewhere else in the docs about this?

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------

James Dunne



More information about the Digitalmars-d mailing list