Operator Overloading in Clojure

后端 未结 2 1690
谎友^
谎友^ 2021-01-07 22:36

Even looking closely over documentation on Clojure, I do not see any direct confirmation as to whether or not Clojure supports operator overloading.

If it d

2条回答
  •  难免孤独
    2021-01-07 23:25

    Take a look at this: http://clojure.org/multimethods

    Certain functions, like + are core and cannot be redefined.

    You could make a new function and call it ".+" or "!+" for example, which is similar in terms of readability.

    Using the information in the multimethods URL included above, you can build a function that tells your .+ which implementation to use.

提交回复
热议问题