/[cmucl]/src/code/setf-funs.lisp
ViewVC logotype

Contents of /src/code/setf-funs.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed May 8 15:46:20 1991 UTC (22 years, 11 months ago) by ram
Branch: MAIN
Initial revision
1 ;;; -*- Package: Kernel -*-
2 ;;;
3 ;;; **********************************************************************
4 ;;; This code was written as part of the CMU Common Lisp project at
5 ;;; Carnegie Mellon University, and has been placed in the public domain.
6 ;;; If you want to use this code or any part of CMU Common Lisp, please contact
7 ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
8 ;;;
9 (ext:file-comment
10 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/setf-funs.lisp,v 1.1 1991/05/08 15:46:20 ram Exp $")
11 ;;;
12 ;;; **********************************************************************
13 ;;;
14 ;;; Stuff to automatically generate SETF functions for all the standard
15 ;;; functions that are currently implemented with setf macros.
16 ;;;
17 (in-package "KERNEL")
18
19 (eval-when (compile eval)
20
21 (defun compute-one-setter (name type)
22 (let* ((args (second type))
23 (res (type-specifier
24 (single-value-type
25 (values-specifier-type (third type)))))
26 (arglist (loop repeat (1+ (length args)) collect (gensym))))
27 (cond
28 ((null (intersection args lambda-list-keywords))
29 `(defun (setf ,name) ,arglist
30 (declare ,@(mapcar #'(lambda (arg type)
31 `(type ,type ,arg))
32 arglist
33 (cons res args)))
34 (setf (,name ,@(rest arglist)) ,(first arglist))))
35 ((ignore-errors (get-setf-method `(apply #',name args)))
36 `(defun (setf ,name) (newval &rest args)
37 (setf (apply #',name args) newval)))
38 (t
39 (warn "Hairy setf expander for function ~S." name)
40 nil))))
41
42
43 (defmacro define-setters (packages &rest ignore)
44 (collect ((res))
45 (dolist (pkg packages)
46 (do-external-symbols (sym pkg)
47 (when (and (fboundp sym)
48 (eq (info function kind sym) :function)
49 (or (info setf inverse sym)
50 (info setf expander sym))
51 (not (member sym ignore)))
52 (let ((type (type-specifier (info function type sym))))
53 (assert (consp type))
54 (res `(declaim (inline (setf ,sym))))
55 (res (compute-one-setter sym type))))))
56 `(progn ,@(res))))
57
58 ); eval-when (compile eval)
59
60 (define-setters ("LISP")
61 aref bit sbit)

  ViewVC Help
Powered by ViewVC 1.1.5