rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Missing try/finally

Open jurgenvinju opened this issue 1 year ago • 0 comments

Describe the bug

I would like to be able to write try-finally blocks like so:

try {
 ...
}
finally {
  ...
}

but this is not in the syntax of Rascal.

Example usage:

void job(str label, void (void () step) block) {
   try {
     jobStart(label);
     block(() { jobStep(label, label, work=1);});
   }
   catch x: {
     throw x; // this rethrow erases the location of the original, also it doesn't add functionality to the code.
   }
   finally {
     jobEnd(label); // this is essential. I need to do this also when exceptions pop the stack.
   }
}

jurgenvinju avatar Mar 23 '24 18:03 jurgenvinju