▲ | geokon 3 days ago | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This example just scratches the surface. I don't think it's showing any Clojure-magic per se, b/c in effect what you're showing is just "implementing an interface". You can do that in most languages. The magic of protocol/records is that they work across library boundaries. A library may provide a record - and then you can extend the record with new protocols. Key is that it's all without needing to explicitly creating new agglomeration types. You can take some Dog record from some pet-simulation library and then `extend-type` it with the IPageObject protocol and make the Dog record now something that can be displayed on a webpage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | roenxi 3 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The magic of Clojure is that if a problem can be solved with an interface Clojure lets you solve it with an interface. It doesn't have any magic to show off, it is just a relentless implementation of a lot of basic good ideas. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | adityaathalye 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> This example just scratches the surface. It most certainly does. The point is to help people lay eyes on the shape of code, in context of a public concept. The post I've submitted is the "Clojure-magic" deep-dive you want! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | manx 3 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sounds like type-classes from haskell/scala? Or is that a different thing? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|