An idea for TCP closures and rust's effect system

... meanwhile I was thinking about making non-local returns a new sort of panic:

// reserves space on stack for NonLocalReturnType
// keeps track of current stack frame so that we can return to it
let catcher = PanicCatcher<RegularReturnType, NonLocalReturnType>::new();

// pass it into the new catch_unwind
catch_unwind_nonlocal(&mut catcher, |nonLocalReturn : &PanicInvoker<NonLocalReturnType>| {
        ....
        let value : NonLocalReturnType = ...;
        nonLocalReturn.panic(value); // can be in another method, just pass nonLocalReturn to it
        ....
    });

if (catcher.isOk()) { ...} else {..}
2 Likes