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

0 votes
in Clojure by
edited by

In source code I have noticed that Keyword class doesn't extend AFn and there are a lot of invoke declarations, which can be removed by extending AFn. And for that purpose AFn, I suppose, exists.

So why Keyword doesn't extend AFn? And comparing with Symbol behaviour, shouldn't it be considering as a bug?
`
(instance? clojure.lang.AFn :asdf)
=> false

(instance? clojure.lang.AFn 'asdf)
=> true
`

1 Answer

0 votes
by

AFn is an implementation detail, so definitely should not be considered a bug (IFn is the public contract here). Off the top of my head, I don't know why one of those extends AFn and one does not, would require some code archeology to make a guess at that, probably could be the same. But we don't generally change working stuff without some good reason, so no reason to change this now.

...