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/catch would need to be removed
Introduce try to 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")
}
Value
setjmp
/longjmp
try/catch
would need to be removedtry
to 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.try/catch
Additionally for this to be really useful we would need https://github.com/buzz-language/buzz/issues/105 so we could write