ClojureCLR

Case expression with Type argument and matches failes

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

(defn f[x]
(case (class x)
Exception 1
String 2))

(f "asdf") => throws

(reported by Ramsey Nasser)

Activity

Hide
Jeremy R Sellars added a comment -

This sounds like a feature request to Clojure (JVM) more than a defect in ClojureCLR.

  • Pros:
    • This would be convenient.
  • Cons:
    • For what it's worth, it doesn't look like Clojure (JVM) supports case switching on Class/Type (in 1.8, 1.9-alpah14). IllegalArgumentException No matching clause: class java.lang.String
    • My perception is that case is analogous to Java/C#'s switch which offers performance benefits over something like cond/condp by jumping to the right code. That benefit might be a trick to maintain for Type, given the opaque nature of .NET's hashing algorithm.
Show
Jeremy R Sellars added a comment - This sounds like a feature request to Clojure (JVM) more than a defect in ClojureCLR.
  • Pros:
    • This would be convenient.
  • Cons:
    • For what it's worth, it doesn't look like Clojure (JVM) supports case switching on Class/Type (in 1.8, 1.9-alpah14). IllegalArgumentException No matching clause: class java.lang.String
    • My perception is that case is analogous to Java/C#'s switch which offers performance benefits over something like cond/condp by jumping to the right code. That benefit might be a trick to maintain for Type, given the opaque nature of .NET's hashing algorithm.
Hide
David Miller added a comment -

Given that ClojureJVM and ClojureCLR agree on this, I prefer not to make a change.
perhaps a type-case construct?

Show
David Miller added a comment - Given that ClojureJVM and ClojureCLR agree on this, I prefer not to make a change. perhaps a type-case construct?

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: