2 ms·
Basically that's what Lisp did with assoc-lists and property-lists since the dawn of time. CL-USER 63 > (pprint *players*) #((:NAME (:FIRST "Jose" :LA
by lispm 11y ago
Basically that's what Lisp did with assoc-lists and property-lists since the dawn of time.
CL-USER 63 > (pprint *players*)
#((:NAME (:FIRST "Jose" :LAST "Peraza") :STATS (:STOLEN-BASES 35 :HOME-RUNS 6) :POSITION :SS)
(:NAME (:FIRST "Mike" :LAST "Trout") :STATS (:STOLEN-BASES 15 :HOME-RUNS 36) :POSITION :OF)
(:NAME (:FIRST "Manny" :LAST "Machado") :STATS (:STOLEN-BASES 20 :HOME-RUNS 30) :POSITION :SS))
CL-USER 64 > (elt *players* 0)
(:NAME (:FIRST "Jose" :LAST "Peraza") :STATS (:STOLEN-BASES 35 :HOME-RUNS 6) :POSITION :SS)
CL-USER 65 > (getf * :position)
:SS
CL-USER 66 > (loop for p across *players*
sum (getf (getf p :stats) :home-runs))
72
Later various dynamic object systems have been written for Lisp, for example the Common Lisp Object System (CLOS). 'Dynamic' means that they don't have the drawbacks of the static object systems, but still provide many of the advantages of OOP.