Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use definterface in Clojure?

Tags:

clojure

It seems that Clojure 1.2.0 has a definterface form, apparently for creating Java interfaces, and some people recommend using it (e.g. one answer to this number crunching question). However, I cannot seem to find any documentation or substantial examples of how to use it. Am I not looking in the right place, or is it actually such an early feature that it should not be used? I'm interested in pointers to documentation or examples demonstrating the features of definterface.

like image 366
Jouni K. Seppänen Avatar asked Dec 06 '25 07:12

Jouni K. Seppänen


1 Answers

Have a look at the documentation of gen-interface.

The rough form is:

(definterface Foo
  [bar [Arg1Type Arg2Type] ReturnType]
  [sideEffects [int] void]
  ...)

EDIT: You are right. The interface is closer to that of defprotocol than that of gen-interface.

(definterface Foo
  [^int foo [x ^String y]]
  [^void bar [^ints is]])
like image 159
kotarak Avatar answered Dec 07 '25 22:12

kotarak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!