IMO that would needlessly complicate an otherwise simple construct,
especially since a simple macro can endlessly customise it.

Thanks,
Ambrose


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

> That works perfectly, thanks!
>
> It does feel like it should just work as a normal case statement though,
> where the value is static final, and warn if it isn't. Is there a good
> reason this shouldn't be supported by the case statement that anyone can
> think of? Worth filing an enhancement request on clojure core?
>
> Thanks,
> Adam
>
>
> Adam
>
>
> On Fri, Feb 28, 2014 at 4:21 PM, Ambrose Bonnaire-Sergeant <
> abonnaireserge...@gmail.com> wrote:
>
>> 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.
>>
>
>  --
> 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