[REBOL] Re: Words with no value error
From: antonr:iinet:au at: 9-Jan-2004 13:18
Yes, as Andreas shows, there problem is when the
try block returns an unset! value. eg:
>> if error? err: try [print "hi"]
** Script Error: err needs a value
** Near: if error? err: try [print "hi"]
Why did that happen?
try does the code block, and returns the last value, or
an armed error! object if there was an error.
But print doesn't return a value, so unset! is returned
(this is not an error).
err: is a set word and when it is done it expects a value.
unset! isn't good enough to be considered a value, so you
get the error message above.
The solution most of us have settled on is to use set/any, like this:
>> if error? set/any 'err try [print "hi"][print mold disarm err]
Using set/any allows the word 'err to also be set to an unset! as well
as all the usual values.