diff options
Diffstat (limited to 'notes')
| -rw-r--r-- | notes/goto_improved.txt | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/notes/goto_improved.txt b/notes/goto_improved.txt index d1def4b..2afab4e 100644 --- a/notes/goto_improved.txt +++ b/notes/goto_improved.txt @@ -66,3 +66,82 @@ Syntax test with assertion failure section: error "Oops" return false end + +Alternative solution 1: Blocks for error/success/finally only +------------------------------------------------------------- + +Allow only "sections" as endings of functions. And only allow +allow error/success/finally? Like this: + + func example + int i + code + ... + on error + ... + on success + ... + finally + ... + end + +Alternative solution 2: Blocks for error/return only +----------------------------------------------------- + +Or, perhaps skip the `on success` part? +And rename `finally` to something that does not imply that it is executed in +abnormal circumstances (e.g. thread termination)? + + func example + int i + code + ... + on error + ... + on return + ... + end + +Alternative solution 3: A before-return block only +-------------------------------------------------- + +Skip the distinction between success and errors (and of course don't try to +handle thread terminiation): + + func example + int i + code + ... + last + ... + end + +The `last` block can only access outermost-scoped variables that are +initialized before the first return. + +In the example below, it should definitely be able to access `a`, but +perhaps not `b` since it hasn't been "merged" to the outermost scope at +the point of the return. + + func example + int i + code + int a + int b + if i == 0 + a = 1 + else + a = 2 + end + if i == 1 + b = 1 + else + b = 2 + if i == 3 + return + end + end + ... + last + ... + end |
