How to check if a record implements a function of a protocol

85 views
Skip to first unread message

Timur

unread,
Nov 22, 2015, 2:28:07 PM11/22/15
to Clojure
Hi,

A record realizes a protocol but does not implement all functions of it. Is there a function to find out if a specific one is implemented or not?

Simple example:

(defprotocol IPro
   (fn1 [_] )
   (fn2 [_] ))


(defrecord MyRecord []
   IPro
   (fn1 [_] "Test1|))

I want to check if MyRecord realizes fn2 or not.

Ghadi Shayban

unread,
Nov 22, 2015, 3:45:32 PM11/22/15
to Clojure
Not possible.  A type/record should not implement a protocol incompletely (though the compiler won't bark at you).  It can be an indication that the protocol is too large/ill-conceived.

Inspecting types is antithetical to using protocols...
Reply all
Reply to author
Forward
0 new messages