From b500e8a044b964db4baff9e387d0ddd1748eb690 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Wed, 24 Apr 2013 16:51:52 +0100 Subject: [PATCH] Defstruct copier function --- ecmalisp.lisp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)) -- 1.7.10.4