source: trunk/j/src/org/armedbear/lisp/symbol.lisp @ 4169

Last change on this file since 4169 was 4169, checked in by piso, 19 years ago

REMPROP is now implemented in Primitives.java.

File size: 2.1 KB
Line 
1;;; symbol.lisp
2;;;
3;;; Copyright (C) 2003 Peter Graves
4;;; $Id: symbol.lisp,v 1.7 2003-10-02 00:03:54 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 getf (place indicator &optional (default ()))
25  (do ((plist place (cddr plist)))
26      ((null plist) default)
27    (cond ((atom (cdr plist))
28     (error 'type-error "malformed property list: ~S" place))
29    ((eq (car plist) indicator)
30     (return (cadr plist))))))
31
32(defun %putf (place property new-value)
33  (do ((plist place (cddr plist)))
34      ((endp plist) (list* property new-value place))
35    (when (eq (car plist) property)
36      (setf (cadr plist) new-value)
37      (return place))))
38
39(defsetf getf %putf)
40
41(defun get-properties (place indicator-list)
42  (do ((plist place (cddr plist)))
43      ((null plist) (values nil nil nil))
44    (cond ((atom (cdr plist))
45     (error 'type-error
46                  "malformed property list: ~S" (list place)))
47    ((memq (car plist) indicator-list)
48     (return (values (car plist) (cadr plist) plist))))))
49
50(defun copy-symbol (symbol &optional (copy-props nil) &aux new-symbol)
51  (setq new-symbol (make-symbol (symbol-name symbol)))
52  (when copy-props
53    (when (boundp symbol)
54      (set new-symbol (symbol-value symbol)))
55    (setf (symbol-plist new-symbol) (copy-list (symbol-plist symbol)))
56    (when (fboundp symbol)
57      (setf (symbol-function new-symbol) (symbol-function symbol))))
58  new-symbol)
Note: See TracBrowser for help on using the repository browser.