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?
deftype and defprotocol define dynamic behavior in Clojure. In Racket, we'd do things like that with struct or struct-property, although there's nothing quite like defprotocol in Racket.
Edit: Racket now has generics, which are like Clojure protocols.
reify and extend, I think, correspond to uses of make-struct-type in 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With