Type initialization / Structures

;; Clojure draws no line between a class and a structure:
;; both are the same thing - a map, or a record made by defrecord

(def rect {:size {:width 10 :height 10}
           :point {:top 5 :left 5}})

(println "width is" (get-in rect [:size :width]))
(println "left is" (get-in rect [:point :left]))

;; a record without its constructor: map->Size takes the fields
;; by name, and the ones left out stay nil
(defrecord Size [width height])
(prn (map->Size {:width 10}))
(prn (map->Size {:width 10 :height 10}))