chapter fifteen

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 Java interoperation. These functions allow for low level integration with Java, for example to provide framework extensions, inheriting from concrete classes, access to "super" (a pointer to the superclass) and so on.

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

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.1.1  name

15.1.2  find-keyword

15.2  type checking

15.2.1  type, instance? and class

15.3  gen-class and gen-interface

15.3.1  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