by geokon · 3mo ago · 0 comments
I'm honestly extremely surprised. Protocols seem sort of essential if you want two different "things" to exhibit the same behavior.
The whole set of immutable datastructures are fundamentally backed by them (well they use Java Interfaces but its fundamentally the same). Not entirely sure how youd implement them without Protocols
Theyre also sort of essential if you want plug-in backends for any part of your codebase.
Im curious what your go-to is currently? Do you just write multimethods and dispatch on the inferred input type?
Also, as I described above in the blog post, protocols/interfaces aren't needed to implement Clojure's object model either. They're just one approach. They're the nominal typing approach, in contrast with something like the structural typing approach, documented in the blog post. For that, we use C++20 concepts for structural typing predicates.