clojure — correct way to locally override operators such as “+”, “*”, etc

前端 未结 4 1695

What is the correct way to override a method like \"+\"? Right now I have

(defn- + [x y] (replacement x y))

but this results in warnings on the

4条回答
  •  我寻月下人不归
    2021-02-12 15:02

    Are you sure you want to do this? If yes, you could use defprotocol to specify what operators you want to override and extend the classes for which you want these overrides implemented. For a (contrived) example see my answer to this question.

提交回复
热议问题