|
|
|
|
|
by mmaniac
590 days ago
|
|
The most interesting part of this article for me is at the beginning. > Now imagine that calls could specify alternate return points, letting the callee decide the statement to return to: // Dreamed-up syntax
fn f() {
g() alternate |x| {
dbg!(x); // x = 123
};
}
fn g() -> () alternate i32 {
return_alternate 123;
}
This sort of nonlocal control flow immediately calls to mind an implementation in terms of continuation passing style, where the return point is given as a function which is tail called. Nonlocal returns and multiple returns are easy to implement in this style.Does there exist a language where some function fn foo() -> T throws U
is syntactic sugar for something more like? fn foo(ifOk: fn(T) -> !, ifExcept: fn(U) -> !) -> !
|
|