Scope/block behaviour

Eduardo Cavazos wayo.cavazos at gmail.com
Thu Aug 19 05:06:50 PDT 2010


Hello,

I was surprised that these seem to not be allowed in D:

void main ()
{
   auto a = 20 ;

   {
     auto a = 30 ;
   }
}

void main ()
{
   { int f0 () { return 10 ; } }

   { int f0 () { return 20 ; } }
}

Perhaps I missed something in the FAQ.

Is there anywhere (manual or TDPL) I can read up on this language design 
decision? What other contemporary (or classic) languages feature this 
behaviour? Scheme and C both allow the above.

It seems like this would be something that might be nice for certain 
shops to enforce via a compiler switch, but not on by default.

Ed


More information about the Digitalmars-d mailing list