15 Types, classes, hierarchies and polymorphism

 

The next section explores the functions dedicated to manage or generate new types.

A first group of functions is mainly dedicated to the interoperability with the Java type system. These functions allow close integration with Java types and interfaces, for example to provide framework extensions, class inheritance, access to super-classes and so on.

A second group of functions implements Clojure "object orientation" point of view. Clojure’s stance on object oriented programming departs from classic Java in at least two important aspects: it does not allow concrete inheritance and it separates inheritance from interface declaration. The latter is often referred as "a-la carte polymorphism" [228].

The chapter opens with a group of functions dedicated to checking, converting or creating Clojure core types. It then moves to more structured and custom ones, starting from functions closer to Java semantic and moving up to functions expressing Clojure approach to polymorphism:

15.1 symbol and keyword

15.2 Type Checking and Coercion

15.3 gen-class and gen-interface

15.4 deftype and definterface

15.5 proxy

15.6 reify

15.7 defrecord

15.8 defprotocol

15.9 extend, extend-type and extend-protocol

15.10 derive and make-hierarchy

15.11 defmulti and defmethod

15.12 Summary