I'm not 100% sure if this works, but have you tried writing a macro that
gets the
Java field value, and inserting into the case statement?

(defmacro motion-case [...]
  `(case ..
     ~MotionEvent/ACTION_POINTER_DOWN ...
  ~ MotionEvent/ACTION_UP ...
))


On Sat, Mar 1, 2014 at 12:15 AM, Adam Clements <adam.cleme...@gmail.com>wrote:

> I'm having some trouble with java constants in a case statement. I know I
> could use condp, but these are things I could put in a java switch
> statement and so it's annoying to give up constant time dispatch:
>
> (case (.getActionMasked event)
>    MotionEvent/ACTION_POINTER_DOWN :down
>    MotionEvent/ACTION_UP           :up
>    MotionEvent/ACTION_POINTER_UP   :up
>    MotionEvent/ACTION_MOVE         :move
>    MotionEvent/ACTION_CANCEL       :cancel
>    MotionEvent/ACTION_OUTSIDE      :outside
>    :none))
>
> Always gives me :none because java constants aren't literals, it
> dispatches on the symbol instead. Is there a way to do this without
> resorting to condp = or am I stuck? Should this be a something that case
> handles by default? I can't think of a reason these couldn't be converted
> to literals...
>
> Thanks,
>
> Adam
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to