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 interoperation 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" [231].

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.2  type checking

 
 
 
 

15.2.1  type, instance? and class

 
 
 
 

15.2.2  instance?

 
 
 
 

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

 
 
 

15.12  Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest