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!:

>> type? first [none]
== word!
>> type? none
== none!

The none in brackets is not an evaluated none. Evaluation makes the word
none a value-of-type-none! none. 

>> type? do [none]
== none!
>> type? do first [none]
== none!

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

2. The Solution:
You can do or reduce (you get the value, or a block containing the value:)

>> type? first reduce [none]
== none!
>> type? do [none]
== none!

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

Hope this helps,






;- Elan >> [: - )]

Reply via email to