D - auto with, and {} scope
- Mike Wynn (57/57) Feb 05 2003 the following
 
the following
auto class foo
{
 this() { printf("foo{\n"); }
 ~this() { printf("}foo\n"); }
 void show() { printf(" ...\n"); }
}
int main( char[][] argv )
{
 auto foo f;
 printf("open [\n");
 {
  f = new foo();
  f.show();
 }
 printf("] close\n");
 return 0;
}
prints
open [
foo{
 ...
] close
}foo
I think this a confusing, either the `auto foo f;` should not be allowed, or
the destructor should be called on the exit of the scope within which the
auto object it created;
is allowing with to be used to create an auto scope a feature that is likely
to be added ?
i.e.
with( new foo() )
{
    show();
}
;
as it stands (0.52)
the code
int main( char[][] argv )
{
 printf("open [\n");
 {
  auto foo f = new foo();
  with( f ) {
   show();
  }
 }
 printf("] close\n");
 return 0;
}
will not compile -- : variable __withSym reference to auto class must be
auto  !!!
and
auto with( ... ) {
}
or
auto( new foo() ) {  }
will  crash the compiler.
 Feb 05 2003








 
 
 
 "Mike Wynn" <mike.wynn l8night.co.uk>