Hacker News new | ask | show | jobs
by onetom 1036 days ago
Also Clojure decomplects inheritance and interfaces.

It gives you protocols to define a set of related methods, without any restriction on the underlying data structure.

It gives you defrecord & deftype to define composite associative data structures, which the fields in an object are.

Then you can combine these in various ways, giving you all sorts of polymorphic code.

Clojure even has multimethods for cases, when a single operation should happen different ways, depending on some aspect of an arbitrary data structure. Someone defines a transformation function from arbitrary data to some other data to dispatch behavior over, then anyone can add define behavior for new dispatch values.

Why not copy these approaches?

1 comments

This approach is already there in Common Lisp, and the biggest flavours that predated it.

I think is the whole point of Scheme community always having been a different set of folks.

In a way, it is like the C versus C++ communities of parenthesis based languages.