X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fmacros.lisp;h=9d4bbd8ee53e201f532f4c287e45a9aeb3ee0727;hb=e8b69b1dd5564a4237b1bdc1060820c3b820cde2;hp=70130803c9b26703d96e5bbffd9b60987b88f791;hpb=568b75331113ecd0601449f337557cd1c1776e8d;p=sbcl.git diff --git a/src/pcl/macros.lisp b/src/pcl/macros.lisp index 7013080..9d4bbd8 100644 --- a/src/pcl/macros.lisp +++ b/src/pcl/macros.lisp @@ -23,8 +23,10 @@ ;;;; This software is made available AS IS, and Xerox Corporation makes no ;;;; warranty about the software, its performance or its conformity to any ;;;; specification. - + (in-package "SB-PCL") + +(/show "starting pcl/macros.lisp") (declaim (declaration ;; These three nonstandard declarations seem to be used @@ -37,55 +39,51 @@ ;; information around, I'm not sure. -- WHN 2000-12-30 %variable-rebinding)) +(/show "done with DECLAIM DECLARATION") + ;;; FIXME: This looks like SBCL's PARSE-BODY, and should be shared. (eval-when (:compile-toplevel :load-toplevel :execute) + (defun extract-declarations (body &optional environment) ;;(declare (values documentation declarations body)) (let (documentation - declarations - form) + declarations + form) (when (and (stringp (car body)) - (cdr body)) + (cdr body)) (setq documentation (pop body))) (block outer (loop - (when (null body) (return-from outer nil)) - (setq form (car body)) - (when (block inner - (loop (cond ((not (listp form)) - (return-from outer nil)) - ((eq (car form) 'declare) - (return-from inner t)) - (t - (multiple-value-bind (newform macrop) - (macroexpand-1 form environment) - (if (or (not (eq newform form)) macrop) - (setq form newform) - (return-from outer nil))))))) - (pop body) - (dolist (declaration (cdr form)) - (push declaration declarations))))) + (when (null body) (return-from outer nil)) + (setq form (car body)) + (when (block inner + (loop (cond ((not (listp form)) + (return-from outer nil)) + ((eq (car form) 'declare) + (return-from inner t)) + (t + (multiple-value-bind (newform macrop) + (macroexpand-1 form environment) + (if (or (not (eq newform form)) macrop) + (setq form newform) + (return-from outer nil))))))) + (pop body) + (dolist (declaration (cdr form)) + (push declaration declarations))))) (values documentation - (and declarations `((declare ,.(nreverse declarations)))) - body))) + (and declarations `((declare ,.(nreverse declarations)))) + body))) ) ; EVAL-WHEN +(/show "done with EVAL-WHEN (..) DEFUN EXTRACT-DECLARATIONS") + (defun get-declaration (name declarations &optional default) (dolist (d declarations default) (dolist (form (cdr d)) (when (and (consp form) (eq (car form) name)) (return-from get-declaration (cdr form)))))) -(defmacro collecting-once (&key initial-value) - `(let* ((head ,initial-value) - (tail ,(and initial-value `(last head)))) - (values #'(lambda (value) - (if (null head) - (setq head (setq tail (list value))) - (unless (memq value head) - (setq tail - (cdr (rplacd tail (list value))))))) - #'(lambda nil head)))) +(/show "pcl/macros.lisp 85") (defmacro doplist ((key val) plist &body body &environment env) (multiple-value-bind (doc decls bod) @@ -100,6 +98,8 @@ (setq ,val (pop .plist-tail.)) (progn ,@bod))))) +(/show "pcl/macros.lisp 101") + (defmacro dolist-carefully ((var list improper-list-handler) &body body) `(let ((,var nil) (.dolist-carefully. ,list)) @@ -116,6 +116,8 @@ ;;;; SBCL deviates from the spec by having CL:FIND-CLASS distinct from ;;;; PCL:FIND-CLASS, alas. +(/show "pcl/macros.lisp 119") + (defvar *find-class* (make-hash-table :test 'eq)) (defmacro find-class-cell-class (cell) @@ -138,6 +140,8 @@ (error "~S is not a legal class name." symbol)) (setf (gethash symbol *find-class*) (make-find-class-cell symbol))))) +(/show "pcl/macros.lisp 157") + (defvar *create-classes-from-internal-structure-definitions-p* t) (defun find-class-from-cell (symbol cell &optional (errorp t)) @@ -180,6 +184,8 @@ ;;; (DECLAIM (TYPE (MEMBER NIL :EARLY :BRAID :COMPLETE) *BOOT-STATE*)) (defvar *boot-state* nil) +(/show "pcl/macros.lisp 187") + ;;; Note that in SBCL as in CMU CL, ;;; COMMON-LISP:FIND-CLASS /= SB-PCL:FIND-CLASS. ;;; (Yes, this is a KLUDGE!) @@ -221,6 +227,8 @@ new-value) (error "~S is not a legal class name." symbol))) +(/show "pcl/macros.lisp 230") + (defun (setf find-class-predicate) (new-value symbol) (if (legal-class-name-p symbol) @@ -230,51 +238,19 @@ (defun find-wrapper (symbol) (class-wrapper (find-class symbol))) -(defmacro gathering1 (gatherer &body body) - `(gathering ((.gathering1. ,gatherer)) - (macrolet ((gather1 (x) `(gather ,x .gathering1.))) - ,@body))) - -(defmacro vectorizing (&key (size 0)) - `(let* ((limit ,size) - (result (make-array limit)) - (index 0)) - (values #'(lambda (value) - (if (= index limit) - (error "vectorizing more elements than promised") - (progn - (setf (svref result index) value) - (incf index) - value))) - #'(lambda () result)))) - -;;; These are augmented definitions of LIST-ELEMENTS and LIST-TAILS from -;;; iterate.lisp. These versions provide the extra :BY keyword which can -;;; be used to specify the step function through the list. -(defmacro *list-elements (list &key (by #'cdr)) - `(let ((tail ,list)) - #'(lambda (finish) - (if (endp tail) - (funcall finish) - (prog1 (car tail) - (setq tail (funcall ,by tail))))))) - -(defmacro *list-tails (list &key (by #'cdr)) - `(let ((tail ,list)) - #'(lambda (finish) - (prog1 (if (endp tail) - (funcall finish) - tail) - (setq tail (funcall ,by tail)))))) +(/show "pcl/macros.lisp 241") (defmacro function-funcall (form &rest args) `(funcall (the function ,form) ,@args)) (defmacro function-apply (form &rest args) `(apply (the function ,form) ,@args)) - -(defun get-setf-function-name (name) +(/show "pcl/macros.lisp 249") + +(defun get-setf-fun-name (name) `(setf ,name)) (defsetf slot-value set-slot-value) + +(/show "finished with pcl/macros.lisp")