With definitional errors, the landscape changes considerably for how we think about error handling.
In this world, there are not a lot of good reasons to use what I call "RECOVER".
By its design, RECOVER will intercept any error in code at any depth. This is what Rebol2's ATTEMPT and TRY did as well, but this made them not the right tool for hardly any code:
rebol2>> attempt [print "Attempting to read file" read %nonexistent-file.txt]
Attempting to read file
== none
rebol2>> attempt [print "Attempting but made typos" rread %nonexistent-file.txt]
== none
The problem isn't just about typos. It's about the illusion that there's something you can do to react to a panic coming form a completely arbitrary stack level beneath you...when the constructs you were using didn't even understand it well enough to pipe it through to their output.
In almost all cases, an error intercepted by "RECOVER" cannot be reacted to sanely...it has to be reported. Such use cases should only be things like consoles and test suites.
It's for this reason that languages like Rust pretty much enforce a panic when a function call produces an error the caller doesn't immediately and explicitly handle.
And our case is even more compelling. For example: How many places is it ever a good idea to sweep a typo under the rug, and just run some other code?
Might We Make It Look More "Special" To Discourage Use?
I thought at minimum we should move it to a place that shows it's more of a "system utility" than a "language feature".
So calling it SYS.UTIL/RECOVER would be a step in that direction.
Things to think about. Anyway, I've made some progress on definitional errors in the scanner and with TO and MAKE operations, so some of the things people like to intercept (like conversions) should work correctly with attempt now.
For instance, in this finite-integer world... an out of range error:
>> try to integer! "10483143873258978444434343"
== \~null~\ ; antiform
>> try to intgeer! "10483143873258978444434343"
** Script Error: intgeer! word is attached to a context, but unassigned
>> to integer! "10483143873258978444434343" except e -> [print ["Error:" mold e]]
Error: make warning! [
type: 'Script
id: 'bad-make-arg
message: ["cannot MAKE/TO" :arg1 "from:" :arg2]
near: [to integer! "10483143873258978444434343" ** except e -> ***]
where: [to args]
file: '
line: 1
arg1: #[datatype! integer!]
arg2: "10483143873258978444434343"
]
Should be a more specific error, now that I look at that. But I guess it just wasn't.