Definition of Clojure Multimethods

I have the following in one namespace shapes::

(derive ::rect ::shape)
(derive ::square ::rect)

Now do the following in the namespace shapes:

(isa? ::square ::shape)

returns true. But when I do the following in a namespace, where I actually implement multimethods for drawing,

(isa? ::square ::shape)

he returns false. Therefore, despite the fact that I have the correct functions for sending multimethods, I get the error message "No sending function was found."

Am I missing something? Realizing all types of shapes in one giant namespace seems meaningless to me.

+5
source share
3 answers

,:: , , : shape/square.

+3

, :: - .

, , , , . , , : geometry/square,: geometry/circle .., .

, , , underive ( ), isa? , . . clojure?

0

You can also use ::with namespace aliases.

(ns some.other.package
  (:require [some.terr.ibly.long.package.name :as short]))

Now: ::short/abcwill be denoted in the same way as:some.terr.ibly.long.package.name/abc

0
source

All Articles