Skip to content

Commit

Permalink
update case macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jianlingzhong committed Jan 27, 2025
1 parent f9b1102 commit 5ccb29a
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions compiler+runtime/src/jank/clojure/core.jank
Original file line number Diff line number Diff line change
Expand Up @@ -3695,12 +3695,6 @@

(defn- case-map-1
[expr-sym default case-f test-f tests thens]
(println "case-map expr-sym" expr-sym)
(println "case-map default" default)
(println "case-map case-f" case-f)
(println "case-map test-f" test-f)
(println "case-map tests" tests)
(println "case-map thens" thens)
(into (sorted-map)
(zipmap (map case-f tests)
(map
Expand Down Expand Up @@ -3767,10 +3761,6 @@
The skip-check is a set of case ints for which post-switch equivalence
checking must not be done (the cases holding the above condp thens)."
[expr-sym default tests thens]
(println "merge-hash-collisions expr-sym" expr-sym)
(println "merge-hash-collisions default" default)
(println "merge-hash-collisions tests" tests)
(println "merge-hash-collisions thens" thens)
(let [buckets
(loop [m {} ks tests vs thens]
(if (and ks vs)
Expand Down Expand Up @@ -3807,10 +3797,6 @@
post-switch equivalence checking must not be done (occurs with hash
collisions)."
[expr-sym default tests thens skip-check]
(println "prep-hashes expr-sym" expr-sym)
(println "prep-hashes default" default)
(println "prep-hashes tests" tests)
(println "prep-hashes thens" thens)
(let [hashes (into #{} (map hash tests))]
(if (== (count tests) (count hashes))
(if (fits-table? hashes)
Expand Down Expand Up @@ -3899,12 +3885,6 @@

:else
:hashes)]
(println "case clauses" clauses)
(println "case mode" mode)
(println "case tests" tests)
(println "case thens" thens)
(println "case pairs" pairs)
(println "case init pairs" (partition 2 clauses))
(condp = mode
:ints
(let [[shift mask imap switch-type] (prep-ints ge default tests thens)]
Expand Down Expand Up @@ -7738,15 +7718,10 @@ fails, attempts to require sym's namespace and retries."
"Parse strings \"true\" or \"false\" and return a boolean, or nil if invalid"
[s]
(if (string? s)
;; TODO: switch `parse-boolean` to case implementation when avaiable
#_(case s
"true" true
"false" false
nil)
(cond
(= "true" s) true
(= "false" s) false
:else nil)
(case s
"true" true
"false" false
nil)
(throw (parsing-err s))))

(def NaN?
Expand Down

0 comments on commit 5ccb29a

Please sign in to comment.