3 ms·
I mean programmatically with an assertion statement or similar. You don't want to add the same assertion before each return statement.
by augustk 6y ago
I mean programmatically with an assertion statement or similar. You don't want to add the same assertion before each return statement.
- darwingr 6y agoI’d love an example if you have one. I’ve used assertions lots as guards or pre-condition checks on entering the function but never right before returning.
- augustk 6y agoA complicated sorting algorithm could assert that the result is sorted before returning.
- raiph 6y agoHopefully you saw Liz's comment. Raku has a zero cost way to add arbitrary post processing that kicks in no matter where or how a block of code exits. This provides a general mechanism accessible by arbitrary user defined control flow related constructs. Raku also ships with a dozen or so built in constructs such as PRE and POST blocks that are the foundational elements for DbC, plus UNDO and KEEP blocks for transactional semantics, and so on.