From ee3389e3bf67eb6742ea0e8ae99f901a2cca3b4b Mon Sep 17 00:00:00 2001 From: Shingo Kitagawa Date: Wed, 15 Dec 2021 01:47:00 +0900 Subject: [PATCH 1/2] show warning message if copy-tree with non list --- lisp/l/common.l | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/l/common.l b/lisp/l/common.l index 4c2c22520..b6624fc28 100644 --- a/lisp/l/common.l +++ b/lisp/l/common.l @@ -433,7 +433,10 @@ if pos is bigger than the length of list, item is nconc'ed at the tail" (defun last (x) (while (consp (cdr x)) (setq x (cdr x))) x) -(defun copy-tree (x) (subst t t x)) +(defun copy-tree (x) + (if (not (listp x)) + (warning-message 1 "copy-tree should be used with list: ~A~%" x)) + (subst t t x)) (defun copy-list (x) (nreverse (reverse x))) (defun nreconc (x y) (nconc (nreverse x) y)) (defun rassoc (item alist) From e602258e59d1b1b2f62349a5ac959aca9c3a1c06 Mon Sep 17 00:00:00 2001 From: Shingo Kitagawa Date: Wed, 15 Dec 2021 19:28:34 +0900 Subject: [PATCH 2/2] add warning in copy-tree manual --- doc/jlatex/jsequences.tex | 6 +++++- doc/latex/sequences.tex | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/jlatex/jsequences.tex b/doc/jlatex/jsequences.tex index 6780e5ffb..37c58123d 100644 --- a/doc/jlatex/jsequences.tex +++ b/doc/jlatex/jsequences.tex @@ -396,7 +396,11 @@ \subsection{リスト} 入れこリストである{\em tree}のコピーを返す。 しかし、環状参照はできない。環状リストは、 {\bf copy-object}でコピーできる。 -実際に、{\bf copy-tree}は{\tt (subst t t tree)}と簡単に記述される。} +実際に、{\bf copy-tree}は{\tt (subst t t tree)}と簡単に記述される。 +なお{\bf copy-tree}は{\em list}しかコピーできず、 +{\em integer-vector, float-vector}などは{\bf copy-seq}を使用しないとコピーできず、 +{\em interger-vector, float-vector}などを含む{\em list}は{\bf copy-object}を +使用しないとディープコピーできない。} \funcdesc{mapc}{func arg-list \&rest more-arg-lists}{ {\em arg-list}や{\em more-arg-lists}それぞれのN番目($N=0,1,\cdots$)の要素からなるリストに diff --git a/doc/latex/sequences.tex b/doc/latex/sequences.tex index ab94ba857..fbd75c0f0 100644 --- a/doc/latex/sequences.tex +++ b/doc/latex/sequences.tex @@ -393,7 +393,10 @@ \subsection{Lists} returns the copy of {\em tree} which may be a nested list but cannot have circular reference. Circular lists can be copied by {\bf copy-object}. -Actually, {\bf copy-tree} is simply coded as {\tt (subst t t tree)}.} +Actually, {\bf copy-tree} is simply coded as {\tt (subst t t tree)}. +Be careful that {\bf copy-tree} only return the copy of {\em list}. +and you need to use {\bf copy-seq} to copy {\em integer-vector, float-vector}, etc., +or {\bf copy-object} to deep-copy {\em list} with {\em integer-vector, float-vector} etc.} \funcdesc{mapc}{func arg-list \&rest more-arg-lists}{ applies {\em func} to a list of N-th elements in {\em arg-list} and each of