26 karma · joined Dec 14, 2020 (5y ago) · 18 submissions
comment 2y ago · link · parent
BTW, the break continue stuff now works in the development branch.
I notice that in that implementation there is an addition to the compiler state with indirections, whereas in ellipsis all is done with just three local variables; two per-function for knowing if we have to unwind completely and for the return value, and one per loop construct to know if we have to unwind there. All the rest is static information about nestedness and lexicographic ordering of code that can be deduced very early (here in the preprocessor). The result of all of this is a very organized braid of gotos, that in general are mostly optimized out.
comment 2y ago · link · parent
Also usually you should be able to have several actions,
defer {
one;
two;
}
And the bounding in the proposed feature is sane, I think, it is the surrounding compound statement (AKA `{ ... }` block).comment 3y ago · link · parent
So it is on the programmer to define what happens on error, they could ignore, try to back off by computing the high value bits, `exit` or `abort`.
comment 5y ago · link · parent
To have a good example where defer inside a loop actually does something, you'd have to capture the value of i. We also have a macro for that in the reference implementation, but that has a much more specialized scope of use.