Ah, thanks Ladislav. I really like your DEFAULT, and I
wish it would be added to Rebol. I even like the name (default),
but I can see it might be seen as a problem (colliding with
other uses of the word), but I think that should not hold it
from being integrated. It could be named "may-fail", "any-fault"
"on-fail" or something like that.
Anton.
> Below is a more "polished" Default version. The Fault block may use
> Error variable "knowing" the error value.
>
> default: func [
> {Execute code. If error occurs, execute fault.}
> [throw]
> code [block!] {Code to execute}
> fault [block!] {Error handling code}
> ] [
> either error? set/any 'code try code [
> fault: make function! [[throw] error [error!]] fault
> fault code
> ] [get/any 'code]
> ]
>
> Examples:
>
> >> default [join "apples" "pears"]["no good"]
> == "applespears"
> >> default [join "apples" "pears" / 0]["no good"]
> == "no good"
> >> default [join "apples" "pears" / 0][print mold disarm error]
>
> make object! [
> code: 312
> type: 'script
> id: 'cannot-use
> arg1: 'divide
> arg2: 'string!
> arg3: none
> near: [join "apples" "pears" / 0]
> where: 'default
> ]
>
> -Ladislav
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.