source: trunk/j/src/org/armedbear/lisp/late-setf.lisp @ 4554

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

Initial checkin.

File size: 2.0 KB
Line 
1;;; late-setf.lisp
2;;;
3;;; Copyright (C) 2003 Peter Graves
4;;; $Id: late-setf.lisp,v 1.1 2003-10-28 02:28:04 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;;; From CMUCL/SBCL.
21
22(in-package "SYSTEM")
23
24(defmacro define-setf-expander (access-fn lambda-list &body body)
25  (require-type access-fn 'symbol)
26  (let ((whole (gensym "WHOLE-"))
27  (environment (gensym "ENV-")))
28    (multiple-value-bind (body local-decs doc)
29       (parse-defmacro lambda-list whole body access-fn
30           'define-setf-expander
31           :environment environment)
32      `(setf (get ',access-fn 'setf-expander)
33             #'(lambda (,whole ,environment)
34                ,@local-decs
35                (block ,access-fn ,body))))))
36
37(define-setf-expander values (&rest places &environment env)
38  (let ((setters ())
39        (getters ())
40        (all-dummies ())
41        (all-vals ())
42        (newvals ()))
43    (dolist (place places)
44      (multiple-value-bind (dummies vals newval setter getter)
45        (get-setf-expansion place env)
46        (setq all-dummies (append all-dummies dummies)
47              all-vals (append all-vals vals)
48              newvals (append newvals newval))
49        (push setter setters)
50        (push getter getters)))
51    (values all-dummies all-vals newvals
52            `(values ,@(reverse setters)) `(values ,@(reverse getters)))))
Note: See TracBrowser for help on using the repository browser.