Return in finally
Frank Benoit (keinfarbton)
benoit at tionex.removethispart.de
Wed Mar 7 10:30:27 PST 2007
While programatically porting Java ...
A finally block cannot contain another try/catch block. This is allowed
in Java. The solution i use is this:
int f(){
try{
} finally {
(){ // start definition of an unnamed function literal
try{
} finally {
// (1)
}
}(); // call it.
}
return 1;
}
Now, i have the first time the situation where at (1) a return statement
occurs. This is not allowed in an a finally block at all [2], and
withing the function literal it would not end the surrounding function.
Any idea, how to simulate
1.) try/catch/finally in a finally
2.) make a return from within a finally
??
[2] not allowed in D, but it is allowed in Java
More information about the Digitalmars-d
mailing list