1 | ;;; symbol.lisp |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2003 Peter Graves |
---|
4 | ;;; $Id: symbol.lisp,v 1.9 2003-12-19 17:25:40 piso Exp $ |
---|
5 | ;;; |
---|
6 | ;;; This program is free software; you can redistribute it and/or |
---|
7 | ;;; modify it under the terms of the GNU General Public License |
---|
8 | ;;; as published by the Free Software Foundation; either version 2 |
---|
9 | ;;; of the License, or (at your option) any later version. |
---|
10 | ;;; |
---|
11 | ;;; This program is distributed in the hope that it will be useful, |
---|
12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | ;;; GNU General Public License for more details. |
---|
15 | ;;; |
---|
16 | ;;; You should have received a copy of the GNU General Public License |
---|
17 | ;;; along with this program; if not, write to the Free Software |
---|
18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | (in-package "SYSTEM") |
---|
21 | |
---|
22 | ;;; From CMUCL. |
---|
23 | |
---|
24 | (defun %putf (place property new-value) |
---|
25 | (do ((plist place (cddr plist))) |
---|
26 | ((endp plist) (list* property new-value place)) |
---|
27 | (when (eq (car plist) property) |
---|
28 | (setf (cadr plist) new-value) |
---|
29 | (return place)))) |
---|
30 | |
---|
31 | (defsetf getf %putf) |
---|
32 | |
---|
33 | (defun get-properties (place indicator-list) |
---|
34 | (do ((plist place (cddr plist))) |
---|
35 | ((null plist) (values nil nil nil)) |
---|
36 | (cond ((atom (cdr plist)) |
---|
37 | (error 'simple-type-error |
---|
38 | :format-control "Malformed property list: ~S." |
---|
39 | :format-arguments (list place))) |
---|
40 | ((memq (car plist) indicator-list) |
---|
41 | (return (values (car plist) (cadr plist) plist)))))) |
---|
42 | |
---|
43 | (defun copy-symbol (symbol &optional (copy-props nil) &aux new-symbol) |
---|
44 | (setq new-symbol (make-symbol (symbol-name symbol))) |
---|
45 | (when copy-props |
---|
46 | (when (boundp symbol) |
---|
47 | (set new-symbol (symbol-value symbol))) |
---|
48 | (setf (symbol-plist new-symbol) (copy-list (symbol-plist symbol))) |
---|
49 | (when (fboundp symbol) |
---|
50 | (setf (symbol-function new-symbol) (symbol-function symbol)))) |
---|
51 | new-symbol) |
---|