Virtual-Binding-Based "Error Propagation Operator" 🤯

Aaaand I've committed it... to my side branch.

This makes a native that acts a bit like Rust's "?" operator so that
if you pass it an ERROR!, it will propagate that with a call to whatever
RETURN is defined as in the local scope.

Hence this:

    trappy: func [] [
        let x: trap 1 * 0
        let y: trap 1 / 0
        return x + y
    ]

Acts equivalently to if you'd written:

    trappy: func [] [
        let x: (1 * 0) except e -> [return fail e]
        let y: (1 / 0) except e -> [return fail e]
        return x + y
    ]

Not a ton of the code is modernized to use definitional failures well... so there aren't actually all that many instances of EXCEPT in the code base to replace with TRAP yet. The exception would be UPARSE, where you can see it tightens things up quite a bit:

New Executables... Soon-ish... I hope...

While it seems like I'll be off on the side branch forever, things are starting to align to where I will hopefully not be too much longer before all these cool features make it to the deployed web console, and a batch of new EXEs.

(The good news about why it's taking so long is because I keep finding solutions to longstanding problems, and I feel like I need to push every solution through as far as it can go until it sort of plateaus, at which point it will be time for a release.)

2 Likes