March 06, 2003
should try/catch blocks create a new scope ?
try.d(14): declaration main.i is already defined
if you remove the commented out if (which does create a new scope) it
compiles
peronally I feel that '{' '}' implies scope.


import c.stdio;

int main( char[][] args )
{
// if( args.length == 0 ) {
 try {
  int i = 0;
  printf( "i:%d\n", i );
 } finally {
  printf( "Done\n" );
 }
// }
 try {
  int i = 1;
  printf( "i:%d\n", i );
 } finally {
  printf( "Done\n" );
 }

 return 0;
}



Top | Discussion index | About this forum | D home