missionary icon indicating copy to clipboard operation
missionary copied to clipboard

Performance warning - case has int tests, but tested expression is not primitive.

Open ggeoffrey opened this issue 1 year ago • 0 comments

This warning shows up when *warn-on-reflection* is set to true.

It comes from amb:

(defmacro
  ^{:arglists '([& forms])
    :doc "In an `ap` block, evaluates each form sequentially and returns successive results."}
  amb
  ([] `(?> none))
  ([form] form)
  ([form & forms]
   (let [n (inc (count forms))]
     `(case (?> (seed (range ~n)))                          ; <- missing `int` cast
        ~@(interleave (range) (cons form forms))))))

(case (int (?> (seed (range ~n)))) …) fixes the issue

The same applies to amb=.

ggeoffrey avatar Nov 05 '22 16:11 ggeoffrey