Hi Elan,

>Hi Michael,
>
>1. The Problem
>2. The Solution
>
>1. The Problem:
>>>> retval: curr-func
>>>> switch retval [none [print "val-none"] "abort" [print "val-abort"]]
>>== none
>>
>>Notice that the == none is the value returned from 'switch, not the
>>execution of the none block. To further illustrate:
>
>
>The reason it didn't work is that
>
>the none in a block, [none], is a value of type word! the none "as we know
>and love it" is a value of type none!:

[snip]

>The same is true for other values/words such as false, true, on, off.

That was very informative and well illustrated. I'd always thought of none,
false etc as values in themselves, probably because my editor highlights the
words. I knew (in the back of my mind) about none! etc but I never took the
time to dissect the differences. I'm kinda surprised now that I hadn't run
into this sort of problem earlier because of my prolific use of 'none.

(BTW I now define $NONE as a standard variable in Perl along with $TRUE and
$FALSE)

>2. The Solution:

[snip]

>To apply it to your problem. Simply reduce the block you pass to switch:
>
>>> retval: none
>== none
>>> switch retval reduce [none [print "val-none"] "abort" [print
"val-abort"]]
>val-none

Yep, that works (of course).

>Hope this helps,

Very much so. Thanks.

- Michael Jelinek

Reply via email to