Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

Currently {{condp}} takes the value of the first argument {{pred}}. This has two disadvantages:

  1. It won't allow macros to be used as the first argument
  2. It will be less efficient since the function calls can't be inlined anymore (common idiom: {{condp = x ...}})

If {{pred}} is a symbol the {{let}} binding can be avoided. This would properly inline {{=}} which is common.

3 Answers

0 votes
by

Comment made by: alexmiller

Concrete examples would help.

0 votes
by

Comment made by: aralo

In my example I have a macro that matches routes. Since they're static this can be optimized during compile time:

(condp route-match? x [:comments :view] 1 [:posts :edit] 2 [_ :delete] 3)

Would also provide a faster assoc for records which generates a condp with identical.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2162 (reported by aralo)
...