www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - restriction in finally no catch

reply Frank Benoit <keinfarbton nospam.xyz> writes:
Actually DMD has the restriction, that a catch in not allowed within a
finally block.

A very simple workaround:

try{
}
catch( Exception e){
}
finally(
  void block(){
    try{
    }
    catch( Exception e){
    }
  }
  block();
}

This is OK for the compiler.
I don't know the reason for this restriction, but
isn't it possible to get rid of it?
Oct 09 2006
parent reply BCS <BCS pathlink.com> writes:
Frank Benoit wrote:
 Actually DMD has the restriction, that a catch in not allowed within a
 finally block.
 
 A very simple workaround:
 
[...] another option: try { } catch( Exception e) { } finally { // delegate literal (){ try { } catch( Exception e) { } }(); // called directly }
Oct 09 2006
parent "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
So if there is a simple workaround like this, why not remove the
restriction?
Oct 22 2006