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

0 votes
in Collections by
The name :or implies this should behave as "or" and be "lazy" but it's not the case currently.
The following gist shows the issue. :x is present in the map but we eval the default value:

(defn foo
  [{:keys [x]
    :or {x (println :set-default)}}]
user> (foo {:x 1})

3 Answers

0 votes

Comment made by: gshayban

1.2 - current all behave this way, doesn't seem like a recent change.

0 votes

Comment made by: mpenet

Right, I thought it might have been a regression, but wasn't sure at all.
It seems it would be safe to change the current behavior, I doubt it would break any ones code.

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