Macro: DEF-CONSTRUCT

Documentation

creates a new datatype using a cons syntax: (def-construct name slot-info slot-info) slot-info ::= slot-name | (slot-name init-form)

Source

(defmacro def-construct (name var1 var2)
  "creates a new datatype using a cons
   syntax: (def-construct name slot-info slot-info)
           slot-info ::= slot-name | (slot-name init-form)"
  (let ((var1-init (if (consp var1) (second var1) 'nil))
	(var2-init (if (consp var2) (second var2) 'nil)))
  `(progn
    
    (defun ,(symb 'make- name) (&optional v1 v2)
      (cons
       (if v1 v1 ,var1-init)
       (if v2 v2 ,var2-init)))

    ,(create-accessors var1 name 'car)
    ,(create-accessors var2 name 'cdr))))
Source Context