-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
The type switch operator is inspired by the ? operator in Rust. Some points:
- The
?operator is inextricably linked withstd::error::Errorand is used for error propagation. - For Whiley, a more general version of it is desirable.
In particular, since we have union types in Whiley, the ? operator should work with them. For example:
function test() -> (int|bool r):
int x = other()?
return x + 1
function other() -> (int|bool r):
1What's happening here is that, by exploiting forward type information from x the ? operator attempts to resolve by pulling out the desired item, otherwise return what is left from the enclosing function. For that to type check, what's left must fit into the return type.
This then allows us to encode exceptional control flow roughly as is done in Rust.
Metadata
Metadata
Assignees
Labels
No labels