This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-29
Channels
- # adventofcode (7)
- # announcements (11)
- # beginners (76)
- # boot (3)
- # calva (139)
- # cider (24)
- # clara (2)
- # cljdoc (11)
- # cljs-dev (90)
- # cljsjs (1)
- # cljsrn (3)
- # clojure (98)
- # clojure-austin (2)
- # clojure-brasil (2)
- # clojure-dev (16)
- # clojure-europe (3)
- # clojure-italy (55)
- # clojure-nl (37)
- # clojure-sweden (11)
- # clojure-uk (40)
- # clojurebridge (1)
- # clojurescript (107)
- # core-logic (10)
- # cursive (34)
- # data-science (9)
- # datascript (19)
- # datomic (48)
- # emacs (6)
- # figwheel (13)
- # figwheel-main (3)
- # fulcro (67)
- # jobs (1)
- # juxt (4)
- # lumo (8)
- # mount (1)
- # off-topic (29)
- # onyx (1)
- # reagent (7)
- # reitit (3)
- # ring-swagger (5)
- # shadow-cljs (39)
- # spacemacs (5)
- # tools-deps (1)
Back to the topic of Records in Clojure and how they differ from Objects in OOP, in the datatype official material, there is this claim: “Tying polymorphism to inheritance is bad” What does it mean exactly?
See above, there was a discussion about records vs. objects
This question asks for clarification
I believe the general idea is that Java style implementation inheritance, where subclasses by default inherit the implementation of their superclass, introduces too much coupling between their implementations.
It's talking about the difference between derived classes, using the extends keyword in Java, and implementing an interface, the implements keyword in Java
So it's saying, what if I want the "talk" function to work with more than one thing. I don't want to write a (talk-x x)
(talk-y y)
, I'd like to instead have (talk x)
(talk y)
where talk is polymorphic on its first argument's type. How can I do that?
In classic Java/C++ OOP, you can only do it by making the type of y Y, inherit from the type of x X or vice versa.
So simply to make talk polymorphic, you're now obligated to create an inheritance hierarchy.
Even though X might not be a Y, it might only share the fact that it also can talk. Nothing more.