[REBOL] Re: Newbie getting head around TRY/DISARM
From: rebol:svendx:dk at: 15-Nov-2000 0:53
Hello Julian,
comments below...
On 15-Nov-00, you wrote:
> Hello Mat,
>
>> IH> if error? set/any error try [ 0/0 ] [
>> IH> error: disarm error
>> IH> print [ "Now you can savely work with: " mold error]
>> IH> ]
>>
>> This doesn't actually work though? Using true to force error to return
>> works though. (so I'm happy!) This just blows out with the actual error and fails
to
>> trap it at all.
>
> There are two problems with this piece of code. First, the error that
> occurs is a syntax error ('0/0' is an invalid date, '0 / 0' is an
> attempt to divide by zero, notice the space). And it appears you can't
> trap syntax errors -
Well, it's tricky at least.
The problem is that the error is triggered before the code is even executed.
compare:
## do "error? try [0/0]"
** Syntax Error: Invalid date -- 0/0.
** Where: (line 1) error? try [0/0]
to:
## error? try [do "0/0"]
== true
>>> error? try [0 / 0]
> == true
>>> error? try [0/0]
> ** Syntax Error: Invalid date -- 0/0.
> ** Where: (line 1) error? try [0/0]
-- snip --
> Julian Kinraid
Best regards
Thomas Jensen