Classes / Constructors

;; Clojure has no inheritance, so there is no parent constructor.
;; the closest thing: one constructor function calls another
(defrecord Man [name])
(defrecord Employee [name position])

(defn make-man [name]
  (->Man name))

(defn make-employee [name position]
  ;; the "parent" builds its part, this one adds its own field
  (map->Employee (assoc (make-man name) :position position)))

(def employee (make-employee "Max" "booker"))

(println "name is" (:name employee))
(println "position is" (:position employee))
(println "employee is" employee)