suggestion: finally for return values

Dan ddaglas at gmail.com
Sat Dec 9 13:14:27 PST 2006


How about modifying D to accept a finally clause for use with function/method
return values.  For example:

int foo(int a, double b) {
  try {
    ...
    return num;
    ...
  } catch (Exception exc) {
    ...
  } finally {
    ...{statements A}...
  } finally(int retval) {
    ...{statements B}...
  }
}

statements B will execute when the try block executes "return num;", passing
num into the finally clause as "retval".  Whether statements A also executes
in this case is up for discussion.

--Dan



More information about the Digitalmars-d mailing list