Clojure has some interesting features for representing types including but not limited to deftype, defprotocol, reify and extend.
What are the similarities and differences between the typing features in Typed Racket and the type-like features in Clojure?
deftypeanddefprotocoldefine dynamic behavior in Clojure. In Racket, we’d do things like that withstructorstruct-property, although there’s nothing quite likedefprotocolin Racket.Edit: Racket now has generics, which are like Clojure protocols.
reifyandextend, I think, correspond to uses ofmake-struct-typein Racket, which creates new structure types dynamically.The big difference between Typed Racket, and all of these features, is that Typed Racket checks your program statically — before trying to run it. You can’t ever apply the wrong accessor in a Typed Racket program, or use a number as a function. You can’t even run a program that might have an error like that.
Currently, the features of Clojure that are most like Typed Racket are the annotations it uses for performance.
Edit: There’s now Typed Clojure by Ambrose Bonnaire-Sergeant, which is inspired and based on Typed Racket.