defstruct
macro
(defstruct name [doc-string] slot*)
Creates predicate, constructor and accessor functions for a prototype with the given slots.
make-html > (macroexpand '(defstruct person name address city (country "nl")))
it: (do
(deftype person #s(:address null :city null :country "nl" :name null))
(defun person? (obj)
(type? obj 'person))
(defun make-person (&rest args)
(apply prototype:new 'person args))
(defun person-name (obj)
(.name obj))
(define-compiler-macro person-name (obj)
(bq:list (bq:list (bq:quote .) (bq:force "name")) (bq:force obj)))
(defun person-address (obj)
(.address obj))
(define-compiler-macro person-address (obj)
(bq:list (bq:list (bq:quote .) (bq:force "address")) (bq:force obj)))
(defun person-city (obj)
(.city obj))
(define-compiler-macro person-city (obj)
(bq:list (bq:list (bq:quote .) (bq:force "city")) (bq:force obj)))
(defun person-country (obj)
(.country obj))
(define-compiler-macro person-country (obj)
(bq:list (bq:list (bq:quote .) (bq:force "country")) (bq:force obj)))
'person)