buzz
buzz copied to clipboard
Migrate to error return value instead of exceptions
- We already have an available tag for errors in
Value - The parsing and type checking would not be impacted
- We could get rid of
setjmp/longjmp - Throwing and returning becomes the same thing
try/catchwould need to be removed- Introduce
tryto be explicit when we propagate errors. This new keyword is required because we will have to implement a new bytecode that returns if an error is raised.
var another = try couldFail(); | return the error if fails
var again = couldFail() catch defaultValue; | default if fails
- New syntax to handle error based on its type to make up for the removed
try/catch
var value = couldFail() catch {
Unexpected -> defaultValue,
else -> panic("you lost me")
}
- Additionally for this to be really useful we would need https://github.com/buzz-language/buzz/issues/105 so we could write
var value = couldFail() catch {
Unexpected -> do {
| ... some complex things
break newValue;
},
else -> panic("you lost me")
}