Clojure

Allow case statement to compare java constants

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

As raised on the mailing list: https://groups.google.com/forum/#!topic/clojure/3yGjDO2YnjQ

It's not possible to use java constants in a case statement. condp = could be used in this case but these are things which could be used in a java switch statement and so it's annoying to give up constant time dispatch. For example:

(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))

Doesn't work, but there is no reason this couldn't be resolved at compile time and dispatched in constant time.

Activity

Hide
Herwig Hochleitner added a comment -

Another solution for this problem: http://dev.clojure.org/jira/browse/CLJ-1368

Show
Herwig Hochleitner added a comment - Another solution for this problem: http://dev.clojure.org/jira/browse/CLJ-1368
Alex Miller made changes -
Field Original Value New Value
Labels interop

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated: