From: David Vázquez Date: Wed, 24 Apr 2013 15:51:52 +0000 (+0100) Subject: Defstruct copier function X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=b500e8a044b964db4baff9e387d0ddd1748eb690;p=jscl.git Defstruct copier function --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 8d5bac5..bf4810b 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -386,7 +386,7 @@ ;; 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)) @@ -408,6 +408,9 @@ ;; 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))