Defstruct copier function
[jscl.git] / ecmalisp.lisp
index 8d5bac5..bf4810b 100644 (file)
   ;; A very simple defstruct built on lists. It supports just slot with
   ;; an optional default initform, and it will create a constructor,
   ;; predicate and accessors for you.
-  (defmacro !defstruct (name &rest slots)
+  (defmacro defstruct (name &rest slots)
     (unless (symbolp name)
       (error "It is not a full defstruct implementation."))
     (let* ((name-string (symbol-name name))
          ;; Predicate
          (defun ,predicate (x)
            (and (consp x) (eq (car x) ',name)))
+         ;; Copier
+         (defun ,(intern (concat "COPY-" name-string)) (x)
+           (copy-list x))
          ;; Slot accessors
          ,@(with-collect
             (let ((index 1))