why scope(success)?
Ben Hinkle
bhinkle at mathworks.com
Thu May 11 08:37:06 PDT 2006
"Stewart Gordon" <smjg_1998 at yahoo.com> wrote in message
news:e3vkhn$1kq5$1 at digitaldaemon.com...
> James Dunne wrote:
> <snip>
>> 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?
>
> I think you're meant to use a bit of common sense here. What sense does
> it make for a declaration to be conditional at runtime?
>
> To be honest, I think a naked declaration as the body of a runtime control
> statement should be illegal.
>
> Stewart.
You're probably right. I had tried dmc and cl and they both complained about
the use of 'a' without a declaration but in fact I was expecting an error
that a declaration can't be the body of an 'if' statement. Since both
compiler didn't say boo about the declaration I figured that declarations
are considered statements. The C99 spec doesn't consider a declaration a
statement so I suspect the compilers are giving poor errors.
More information about the Digitalmars-d
mailing list