Sergey Didenko <[email protected]> writes:

> Is this the intended behavior? Note the present/missing default clause
>
> user> (set! *warn-on-reflection* true)
> user> (case (rand-int 3) 0 :zero 1 :one 2 :two)
> Performance warning, NO_SOURCE_FILE:1 - case has int tests, but tested
> expression is not primitive.
> :two
> user> (case (rand-int 3) 0 :zero 1 :one 2 :two :default 3)
> :two

The default case in `case' (what a sentence) is not paired like in
`cond'.  You want something like:

,----
| user> (case (rand-int 10) 0 :zero 1 :one 2 :two :other)
| Performance warning, NO_SOURCE_FILE:1 - case has int tests, but tested 
expression is not primitive.
| :other
`----

I think the problem with the reflection warning is that `rand-int'
returns a Long.  This version seems to wor:

,----
| (case (int (rand-int 10))
|    0    :zero
|    1    :one
|    2    :two
|    :other)
`----

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to