/[cmucl]/src/code/macros.lisp
ViewVC logotype

Diff of /src/code/macros.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.90.2.1 by gerd, Wed Mar 19 16:45:32 2003 UTC revision 1.120 by rtoy, Tue May 25 20:04:33 2010 UTC
# Line 16  Line 16 
16  ;;; Modified by Bill Chiles to adhere to the wall.  ;;; Modified by Bill Chiles to adhere to the wall.
17  ;;;  ;;;
18  (in-package "LISP")  (in-package "LISP")
19    (intl:textdomain "cmucl")
20    
21  (export '(defvar defparameter defconstant when unless setf  (export '(defvar defparameter defconstant when unless setf
22            defsetf psetf shiftf rotatef push pushnew pop            defsetf psetf shiftf rotatef push pushnew pop
23            incf decf remf case typecase with-open-file            incf decf remf case typecase with-open-file
# Line 75  Line 77 
77  ;;; definition is done by %defmacro which we expand into.  ;;; definition is done by %defmacro which we expand into.
78  ;;;  ;;;
79  (defmacro defmacro (name lambda-list &body body)  (defmacro defmacro (name lambda-list &body body)
80      (when lisp::*enable-package-locked-errors*
81        (multiple-value-bind (valid block-name)
82            (ext:valid-function-name-p name)
83          (declare (ignore valid))
84          (let ((package (symbol-package block-name)))
85            (when package
86              (when (ext:package-definition-lock package)
87                (restart-case
88                    (error 'lisp::package-locked-error
89                           :package package
90                           :format-control (intl:gettext "defining macro ~A")
91                           :format-arguments (list name))
92                  (continue ()
93                    :report (lambda (stream)
94                              (write-string (intl:gettext "Ignore the lock and continue") stream)))
95                  (unlock-package ()
96                    :report (lambda (stream)
97                              (write-string (intl:gettext "Disable the package's definition-lock then continue") stream))
98                    (setf (ext:package-definition-lock package) nil))
99                  (unlock-all ()
100                    :report (lambda (stream)
101                              (write-string (intl:gettext "Unlock all packages, then continue") stream))
102                    (lisp::unlock-all-packages))))))))
103    (let ((whole (gensym "WHOLE-"))    (let ((whole (gensym "WHOLE-"))
104          (environment (gensym "ENV-")))          (environment (gensym "ENV-")))
105      (multiple-value-bind      (multiple-value-bind
106          (body local-decs doc)          (body local-decs doc)
107          (parse-defmacro lambda-list whole body name 'defmacro          (parse-defmacro lambda-list whole body name 'defmacro
108                          :environment environment)                          :environment environment)
109          (when doc
110            (intl::note-translatable intl::*default-domain* doc))
111        (let ((def `(lambda (,whole ,environment)        (let ((def `(lambda (,whole ,environment)
112                      ,@local-decs                      ,@local-decs
113                      (block ,name                      (block ,name
# Line 105  Line 132 
132  ;;;  ;;;
133  (defun c::%defmacro (name definition lambda-list doc)  (defun c::%defmacro (name definition lambda-list doc)
134    (assert (eval:interpreted-function-p definition))    (assert (eval:interpreted-function-p definition))
135    (setf (eval:interpreted-function-name definition)    (setf (eval:interpreted-function-name definition) name)
         (format nil "DEFMACRO ~S" name))  
136    (setf (eval:interpreted-function-arglist definition) lambda-list)    (setf (eval:interpreted-function-arglist definition) lambda-list)
137    (c::%%defmacro name definition doc))    (c::%%defmacro name definition doc))
138  ;;;  ;;;
# Line 124  Line 150 
150    "Define a compiler-macro for NAME."    "Define a compiler-macro for NAME."
151    (let ((whole (gensym "WHOLE-"))    (let ((whole (gensym "WHOLE-"))
152          (environment (gensym "ENV-")))          (environment (gensym "ENV-")))
153      (multiple-value-bind      (multiple-value-bind (validp block-name)
154          (body local-decs doc)          (valid-function-name-p name)
155          (parse-defmacro lambda-list whole body name 'define-compiler-macro        (unless validp
156                          :environment environment)          (simple-program-error (intl:gettext "~S is not a valid function name.") name))
157        (let ((def `(lambda (,whole ,environment)        (multiple-value-bind
158                      ,@local-decs              (body local-decs doc)
159                      (block ,name            (parse-defmacro lambda-list whole body name 'define-compiler-macro
160                        ,body))))                            :environment environment)
161          `(progn          (when doc
162             (eval-when (:compile-toplevel)            (intl::note-translatable intl::*default-domain* doc))
163               (c::do-compiler-macro-compile-time ',name #',def))          (let ((def `(lambda (,whole ,environment)
164             (eval-when (:load-toplevel :execute)                        ,@local-decs
165               (c::%define-compiler-macro ',name #',def ',lambda-list ,doc)))))))                        (block ,block-name
166                            ,body))))
167              `(progn
168                 (eval-when (:compile-toplevel)
169                   (c::do-compiler-macro-compile-time ',name #',def))
170                 (eval-when (:load-toplevel :execute)
171                   (c::%define-compiler-macro ',name #',def ',lambda-list ,doc))))))))
172    
173    
174  (defun c::%define-compiler-macro (name definition lambda-list doc)  (defun c::%define-compiler-macro (name definition lambda-list doc)
# Line 165  Line 197 
197  (defun %define-symbol-macro (name expansion)  (defun %define-symbol-macro (name expansion)
198    (unless (symbolp name)    (unless (symbolp name)
199      (error 'simple-type-error :datum name :expected-type 'symbol      (error 'simple-type-error :datum name :expected-type 'symbol
200             :format-control "Symbol macro name is not a symbol: ~S."             :format-control (intl:gettext "Symbol macro name is not a symbol: ~S.")
201             :format-arguments (list name)))             :format-arguments (list name)))
202    (ecase (info variable kind name)    (ecase (info variable kind name)
203      ((:macro :global nil)      ((:macro :global nil)
# Line 173  Line 205 
205       (setf (info variable macro-expansion name) expansion))       (setf (info variable macro-expansion name) expansion))
206      (:special      (:special
207       (error 'simple-program-error       (error 'simple-program-error
208              :format-control "Symbol macro name already declared special: ~S."              :format-control (intl:gettext "Symbol macro name already declared special: ~S.")
209              :format-arguments (list name)))              :format-arguments (list name)))
210      (:constant      (:constant
211       (error 'simple-program-error       (error 'simple-program-error
212              :format-control "Symbol macro name already declared constant: ~S."              :format-control (intl:gettext "Symbol macro name already declared constant: ~S.")
213              :format-arguments (list name))))              :format-arguments (list name))))
214    name)    name)
215    
# Line 187  Line 219 
219  (defmacro deftype (name arglist &body body)  (defmacro deftype (name arglist &body body)
220    "Syntax like DEFMACRO, but defines a new type."    "Syntax like DEFMACRO, but defines a new type."
221    (unless (symbolp name)    (unless (symbolp name)
222      (simple-program-error "~S -- Type name not a symbol." name))      (simple-program-error (intl:gettext "~S -- Type name not a symbol.") name))
223      (and lisp::*enable-package-locked-errors*
224           (symbol-package name)
225           (ext:package-definition-lock (symbol-package name))
226           (restart-case
227               (error 'lisp::package-locked-error
228                      :package (symbol-package name)
229                      :format-control (intl:gettext "defining type ~A")
230                      :format-arguments (list name))
231             (continue ()
232               :report (lambda (stream)
233                         (write-string (intl:gettext "Ignore the lock and continue") stream)))
234             (unlock-package ()
235               :report (lambda (stream)
236                         (write-string (intl:gettext "Disable package's definition-lock then continue") stream))
237               (setf (ext:package-definition-lock (symbol-package name)) nil))
238             (unlock-all ()
239               :report (lambda (stream)
240                         (write-string (intl:gettext "Unlock all packages, then continue") stream))
241               (lisp::unlock-all-packages))))
242    (let ((whole (gensym "WHOLE-")))    (let ((whole (gensym "WHOLE-")))
243      (multiple-value-bind (body local-decs doc)      (multiple-value-bind (body local-decs doc)
244                           (parse-defmacro arglist whole body name 'deftype                           (parse-defmacro arglist whole body name 'deftype
245                                           :default-default ''*)                                           :default-default ''*)
246          (when doc
247            (intl::note-translatable intl::*default-domain* doc))
248        `(eval-when (:compile-toplevel :load-toplevel :execute)        `(eval-when (:compile-toplevel :load-toplevel :execute)
249             (set-defvar-source-location ',name (c::source-location))
250           (%deftype ',name           (%deftype ',name
251                     #'(lambda (,whole)                     #'(lambda (,whole)
252                         ,@local-decs                         ,@local-decs
# Line 201  Line 254 
254                     ,@(when doc `(,doc)))))))                     ,@(when doc `(,doc)))))))
255  ;;;  ;;;
256  (defun %deftype (name expander &optional doc)  (defun %deftype (name expander &optional doc)
257      (when (info declaration recognized name)
258        (error (intl:gettext "Deftype already names a declaration: ~S.") name))
259    (ecase (info type kind name)    (ecase (info type kind name)
260      (:primitive      (:primitive
261       (when *type-system-initialized*       (when *type-system-initialized*
262         (error "Illegal to redefine standard type: ~S." name)))         (error (intl:gettext "Illegal to redefine standard type: ~S.") name)))
263      (:instance      (:instance
264       (warn "Redefining class ~S to be a DEFTYPE." name)       (warn (intl:gettext "Redefining class ~S to be a DEFTYPE.") name)
265       (undefine-structure (layout-info (%class-layout (kernel::find-class name))))       (undefine-structure (layout-info (%class-layout (kernel::find-class name))))
266       (setf (class-cell-class (find-class-cell name)) nil)       (setf (class-cell-class (find-class-cell name)) nil)
267       (setf (info type compiler-layout name) nil)       (setf (info type compiler-layout name) nil)
# Line 233  Line 288 
288    "Syntax like DEFMACRO, but creates a Setf-Expansion generator.  The body    "Syntax like DEFMACRO, but creates a Setf-Expansion generator.  The body
289    must be a form that returns the five magical values."    must be a form that returns the five magical values."
290    (unless (symbolp access-fn)    (unless (symbolp access-fn)
291      (simple-program-error "~S -- Access-function name not a symbol in DEFINE-SETF-EXPANDER."      (simple-program-error (intl:gettext "~S -- Access-function name not a symbol in DEFINE-SETF-EXPANDER.")
292             access-fn))             access-fn))
293    
294    (let ((whole (gensym "WHOLE-"))    (let ((whole (gensym "WHOLE-"))
# Line 242  Line 297 
297                           (parse-defmacro lambda-list whole body access-fn                           (parse-defmacro lambda-list whole body access-fn
298                                           'define-setf-expander                                           'define-setf-expander
299                                           :environment environment)                                           :environment environment)
300          (when doc
301            (intl::note-translatable intl::*default-domain* doc))
302        `(eval-when (:compile-toplevel :load-toplevel :execute)        `(eval-when (:compile-toplevel :load-toplevel :execute)
303           (%define-setf-macro           (%define-setf-macro
304            ',access-fn            ',access-fn
# Line 263  Line 320 
320  (defun %define-setf-macro (name expander inverse doc)  (defun %define-setf-macro (name expander inverse doc)
321    (cond ((not (fboundp `(setf ,name))))    (cond ((not (fboundp `(setf ,name))))
322          ((info function accessor-for name)          ((info function accessor-for name)
323           (warn "Defining setf macro for destruct slot accessor; redefining as ~           (warn (intl:gettext "Defining setf macro for destruct slot accessor; redefining as ~
324                  a normal function:~%  ~S"                  a normal function:~%  ~S")
325                 name)                 name)
326           (c::define-function-name name))           (c::define-function-name name))
327          ((not (eq (symbol-package name) (symbol-package 'aref)))          ((not (eq (symbol-package name) (symbol-package 'aref)))
328           (warn "Defining setf macro for ~S, but ~S is fbound."           (warn (intl:gettext "Defining setf macro for ~S, but ~S is fbound.")
329                 name `(setf ,name))))                 name `(setf ,name))))
330    (when (or inverse (info setf inverse name))    (when (or inverse (info setf inverse name))
331      (setf (info setf inverse name) inverse))      (setf (info setf inverse name) inverse))
# Line 300  Line 357 
357  ;;;    Very similar to Defmacro, but simpler.  We don't have to parse the  ;;;    Very similar to Defmacro, but simpler.  We don't have to parse the
358  ;;; lambda-list.  ;;; lambda-list.
359  ;;;  ;;;
360  (defmacro defun (&whole source name lambda-list &body (body decls doc))  (defmacro defun (&whole source name lambda-list &parse-body (body decls doc))
361    (multiple-value-bind (valid block-name)    (multiple-value-bind (valid block-name)
362        (valid-function-name-p name)        (valid-function-name-p name)
363      (declare (ignore valid))      (declare (ignore valid))
364        (when doc
365          (intl::note-translatable intl::*default-domain* doc))
366      (let ((def `(lambda ,lambda-list      (let ((def `(lambda ,lambda-list
367                    ,@decls                    ,@decls
368                    (block ,block-name ,@body))))                    (block ,block-name ,@body))))
# Line 315  Line 374 
374  ;;;    Similar to %Defmacro, ...  ;;;    Similar to %Defmacro, ...
375  ;;;  ;;;
376  (defun c::%%defun (name def doc &optional inline-expansion)  (defun c::%%defun (name def doc &optional inline-expansion)
377      (c::define-function-name name)
378    (setf (fdefinition name) def)    (setf (fdefinition name) def)
379    (when doc    (when doc
380      (if (and (consp name) (eq (first name) 'setf))      (if (and (consp name) (eq (first name) 'setf))
381          (setf (documentation (second name) 'setf) doc)          (setf (documentation (second name) 'setf) doc)
382          (setf (documentation name 'function) doc)))          (setf (documentation name 'function) doc)))
   (c::define-function-name name)  
383    (when (eq (info function where-from name) :assumed)    (when (eq (info function where-from name) :assumed)
384      (setf (info function where-from name) :defined)      (setf (info function where-from name) :defined)
385      (when (info function assumed-type name)      (when (info function assumed-type name)
# Line 329  Line 388 
388              (info function inline-expansion name))              (info function inline-expansion name))
389      (setf (info function inline-expansion name) inline-expansion))      (setf (info function inline-expansion name) inline-expansion))
390    name)    name)
391  ;;;  
392  (defun c::%defun (name def doc source)  (defun c::%defun (name def doc source)
393    (declare (ignore source))    (declare (ignore source))
394    (assert (eval:interpreted-function-p def))    (assert (eval:interpreted-function-p def))
395    (setf (eval:interpreted-function-name def) name)    (setf (eval:interpreted-function-name def) name)
396    (c::%%defun name def doc))    (let ((inline-expansion nil))
397        (when (memq (info function inlinep name) '(:inline :maybe-inline))
398          (multiple-value-bind (lambda-expression closure-p)
399              (function-lambda-expression def)
400            (unless closure-p
401              (setq inline-expansion lambda-expression))))
402        (c::%%defun name def doc inline-expansion)))
403    
404    (defun set-defvar-textdomain (name domain)
405      (setf (c::info variable textdomain name) domain))
406    
407  ;;; DEFCONSTANT  --  Public  ;;; DEFCONSTANT  --  Public
408  ;;;  ;;;
# Line 344  Line 411 
411    value is constant and may be compiled into code.  If the variable already has    value is constant and may be compiled into code.  If the variable already has
412    a value, and this is not equal to the init, an error is signalled.  The third    a value, and this is not equal to the init, an error is signalled.  The third
413    argument is an optional documentation string for the variable."    argument is an optional documentation string for the variable."
414      (when doc
415        (intl::note-translatable intl::*default-domain* doc))
416    `(progn    `(progn
417       (eval-when (:compile-toplevel)       (eval-when (:compile-toplevel)
418         (c::do-defconstant-compile-time ',var ,val ',doc))         (c::do-defconstant-compile-time ',var ,val ',doc))
419       (eval-when (:load-toplevel :execute)       (eval-when (:load-toplevel :execute)
420         (c::%%defconstant ',var ,val ',doc))))         (set-defvar-textdomain ',var ,intl::*default-domain*)
421           (c::%%defconstant ',var ,val ',doc (c::source-location)))))
422    
423    (defun set-defvar-source-location (name source-location)
424      (setf (info :source-location :defvar name) source-location))
425    
426  ;;; %Defconstant, %%Defconstant  --  Internal  ;;; %Defconstant, %%Defconstant  --  Internal
427  ;;;  ;;;
# Line 357  Line 430 
430  ;;; redefined.  ;;; redefined.
431  ;;;  ;;;
432  (defun c::%defconstant (name value doc)  (defun c::%defconstant (name value doc)
433    (c::%%defconstant name value doc))    (c::%%defconstant name value doc nil))
434  ;;;  ;;;
435  (defun c::%%defconstant (name value doc)  (defun c::%%defconstant (name value doc source-location)
436    (when doc    (when doc
437      (setf (documentation name 'variable) doc))      (setf (documentation name 'variable) doc))
438    (when (boundp name)    (when (boundp name)
439      (unless (equalp (symbol-value name) value)      (unless (equalp (symbol-value name) value)
440        (cerror "Go ahead and change the value."        (cerror (intl:gettext "Go ahead and change the value.")
441                "Constant ~S being redefined." name)))                (intl:gettext "Constant ~S being redefined.") name)))
442    (setf (symbol-value name) value)    (setf (symbol-value name) value)
443    (setf (info variable kind name) :constant)    (setf (info variable kind name) :constant)
444    (clear-info variable constant-value name)    (clear-info variable constant-value name)
445      (set-defvar-source-location name source-location)
446    name)    name)
447    
   
448  (defmacro defvar (var &optional (val nil valp) (doc nil docp))  (defmacro defvar (var &optional (val nil valp) (doc nil docp))
449    "For defining global variables at top level.  Declares the variable    "For defining global variables at top level.  Declares the variable
450    SPECIAL and, optionally, initializes it.  If the variable already has a    SPECIAL and, optionally, initializes it.  If the variable already has a
451    value, the old value is not clobbered.  The third argument is an optional    value, the old value is not clobbered.  The third argument is an optional
452    documentation string for the variable."    documentation string for the variable."
453      (when docp
454        (intl::note-translatable intl::*default-domain* doc))
455    `(progn    `(progn
456      (declaim (special ,var))      (declaim (special ,var))
457       ,@(when valp       ,@(when valp
458           `((unless (boundp ',var)           `((unless (boundp ',var)
459               (setq ,var ,val))))               (setq ,var ,val))))
460      ,@(when docp      ,@(when docp
461          `((setf (documentation ',var 'variable) ',doc)))          `((setf (documentation ',var 'variable) ',doc)
462              (eval-when (:load-toplevel :execute)
463                (set-defvar-textdomain ',var ,intl::*default-domain*))))
464        (set-defvar-source-location ',var (c::source-location))
465      ',var))      ',var))
466    
467  (defmacro defparameter (var val &optional (doc nil docp))  (defmacro defparameter (var val &optional (doc nil docp))
# Line 391  Line 469 
469    but that may be changed without causing an error.  Declares the    but that may be changed without causing an error.  Declares the
470    variable special and sets its value to VAL.  The third argument is    variable special and sets its value to VAL.  The third argument is
471    an optional documentation string for the parameter."    an optional documentation string for the parameter."
472      (when docp
473        (intl::note-translatable intl::*default-domain* doc))
474    `(progn    `(progn
475      (declaim (special ,var))      (declaim (special ,var))
476      (setq ,var ,val)      (setq ,var ,val)
477      ,@(when docp      ,@(when docp
478          `((setf (documentation ',var 'variable) ',doc)))          `((setf (documentation ',var 'variable) ',doc)
479              (eval-when (:load-toplevel :execute)
480                (set-defvar-textdomain ',var ,intl::*default-domain*))))
481        (set-defvar-source-location ',var (c::source-location))
482      ',var))      ',var))
483    
484    
# Line 416  Line 499 
499  (defmacro return (&optional (value nil))  (defmacro return (&optional (value nil))
500    `(return-from nil ,value))    `(return-from nil ,value))
501    
502  (defmacro prog (varlist &body (body decls))  (defmacro prog (varlist &parse-body (body decls))
503    `(block nil    `(block nil
504       (let ,varlist       (let ,varlist
505         ,@decls         ,@decls
506         (tagbody ,@body))))         (tagbody ,@body))))
507    
508  (defmacro prog* (varlist &body (body decls))  (defmacro prog* (varlist &parse-body (body decls))
509    `(block nil    `(block nil
510       (let* ,varlist       (let* ,varlist
511         ,@decls         ,@decls
# Line 475  Line 558 
558        nil        nil
559        (let ((clause (first clauses)))        (let ((clause (first clauses)))
560          (when (atom clause)          (when (atom clause)
561            (error "Cond clause is not a list: ~S." clause))            (error (intl:gettext "Cond clause is not a list: ~S.") clause))
562          (let ((test (first clause))          (let ((test (first clause))
563                (forms (rest clause)))                (forms (rest clause)))
564            (if (endp forms)            (if (endp forms)
# Line 498  Line 581 
581  ;;;  ;;;
582  (defmacro multiple-value-setq (varlist value-form)  (defmacro multiple-value-setq (varlist value-form)
583    (unless (and (listp varlist) (every #'symbolp varlist))    (unless (and (listp varlist) (every #'symbolp varlist))
584      (error "Varlist is not a list of symbols: ~S." varlist))      (simple-program-error (intl:gettext "Varlist is not a list of symbols: ~S.") varlist))
585    `(values (setf (values ,@varlist) ,value-form)))    (if varlist
586          `(values (setf (values ,@varlist) ,value-form))
587          `(values ,value-form)))
588    
589  ;;;  ;;;
590  (defmacro multiple-value-bind (varlist value-form &body body)  (defmacro multiple-value-bind (varlist value-form &body body)
591    (unless (and (listp varlist) (every #'symbolp varlist))    (unless (and (listp varlist) (every #'symbolp varlist))
592      (error "Varlist is not a list of symbols: ~S." varlist))      (simple-program-error  (intl:gettext "Varlist is not a list of symbols: ~S.") varlist))
593    (if (= (length varlist) 1)    (if (= (length varlist) 1)
594        `(let ((,(car varlist) ,value-form))        `(let ((,(car varlist) ,value-form))
595           ,@body)           ,@body)
596        (let ((ignore (gensym)))        (let ((ignore (gensym)))
597          `(multiple-value-call #'(lambda (&optional ,@varlist &rest ,ignore)          `(multiple-value-call #'(lambda (&optional ,@(mapcar #'list varlist) &rest ,ignore)
598                                    (declare (ignore ,ignore))                                    (declare (ignore ,ignore))
599                                    ,@body)                                    ,@body)
600             ,value-form))))             ,value-form))))
# Line 630  Line 715 
715        (temps value-forms store-vars store-form access-form)        (temps value-forms store-vars store-form access-form)
716        (get-setf-expansion form environment)        (get-setf-expansion form environment)
717      (when (cdr store-vars)      (when (cdr store-vars)
718        (error "GET-SETF-METHOD used for a form with multiple store ~        (error (intl:gettext "GET-SETF-METHOD used for a form with multiple store ~
719                variables:~%  ~S" form))                variables:~%  ~S") form))
720      (values temps value-forms store-vars store-form access-form)))      (values temps value-forms store-vars store-form access-form)))
721    
722    
# Line 642  Line 727 
727      (multiple-value-bind      (multiple-value-bind
728          (body local-decs doc)          (body local-decs doc)
729          (parse-defmacro arglist arglist-var (cddr rest) fn 'defsetf)          (parse-defmacro arglist arglist-var (cddr rest) fn 'defsetf)
730          (when doc
731            (intl::note-translatable intl::*default-domain* doc))
732        (values        (values
733         `(lambda (,arglist-var ,new-var)         `(lambda (,arglist-var ,new-var)
734            ,@local-decs            ,@local-decs
# Line 670  Line 757 
757                   (parse-defmacro `(,lambda-list ,@store-variables)                   (parse-defmacro `(,lambda-list ,@store-variables)
758                                   arglist-var body access-fn 'defsetf                                   arglist-var body access-fn 'defsetf
759                                   :annonymousp t)                                   :annonymousp t)
760                   (when doc
761                     (intl::note-translatable intl::*default-domain* doc))
762                 `(eval-when (load compile eval)                 `(eval-when (load compile eval)
763                    (%define-setf-macro                    (%define-setf-macro
764                     ',access-fn                     ',access-fn
# Line 683  Line 772 
772                     nil                     nil
773                     ',doc))))))                     ',doc))))))
774          (t          (t
775           (error "Ill-formed DEFSETF for ~S." access-fn))))           (error (intl:gettext "Ill-formed DEFSETF for ~S.") access-fn))))
776    
777  (defun %defsetf (orig-access-form num-store-vars expander)  (defun %defsetf (orig-access-form num-store-vars expander)
778    (collect ((subforms) (subform-vars) (subform-exprs) (store-vars))    (collect ((subforms) (subform-vars) (subform-exprs) (store-vars))
# Line 733  Line 822 
822                         (multiple-value-bind ,newval ,value-form                         (multiple-value-bind ,newval ,value-form
823                           ,setter))))))))                           ,setter))))))))
824       ((oddp nargs)       ((oddp nargs)
825        (error "Odd number of args to SETF."))        (error (intl:gettext "Odd number of args to SETF.")))
826       (t       (t
827        (do ((a args (cddr a)) (l nil))        (do ((a args (cddr a)) (l nil))
828            ((null a) `(progn ,@(nreverse l)))            ((null a) `(progn ,@(nreverse l)))
# Line 748  Line 837 
837      (do ((a args (cddr a)))      (do ((a args (cddr a)))
838          ((endp a))          ((endp a))
839        (if (endp (cdr a))        (if (endp (cdr a))
840            (simple-program-error "Odd number of args to PSETF."))            (simple-program-error (intl:gettext "Odd number of args to PSETF.")))
841        (multiple-value-bind        (multiple-value-bind
842            (dummies vals newval setter getter)            (dummies vals newval setter getter)
843            (get-setf-expansion (car a) env)            (get-setf-expansion (car a) env)
# Line 838  Line 927 
927    "Creates a new read-modify-write macro like PUSH or INCF."    "Creates a new read-modify-write macro like PUSH or INCF."
928    (let ((other-args nil)    (let ((other-args nil)
929          (rest-arg nil)          (rest-arg nil)
930          (env (gensym))          (env (gensym "ENV-"))
931          (reference (gensym)))          (reference (gensym "PLACE-")))
932    
933      ;; Parse out the variable names and rest arg from the lambda list.      ;; Parse out the variable names and rest arg from the lambda list.
934      (do ((ll lambda-list (cdr ll))      (do ((ll lambda-list (cdr ll))
# Line 850  Line 939 
939              ((eq arg '&rest)              ((eq arg '&rest)
940               (if (symbolp (cadr ll))               (if (symbolp (cadr ll))
941                   (setq rest-arg (cadr ll))                   (setq rest-arg (cadr ll))
942                   (error "Non-symbol &rest arg in definition of ~S." name))                   (error (intl:gettext "Non-symbol &rest arg in definition of ~S.") name))
943               (if (null (cddr ll))               (if (null (cddr ll))
944                   (return nil)                   (return nil)
945                   (error "Illegal stuff after &rest arg in Define-Modify-Macro.")))                   (error (intl:gettext "Illegal stuff after &rest arg in Define-Modify-Macro."))))
946              ((memq arg '(&key &allow-other-keys &aux))              ((memq arg '(&key &allow-other-keys &aux))
947               (error "~S not allowed in Define-Modify-Macro lambda list." arg))               (error (intl:gettext "~S not allowed in Define-Modify-Macro lambda list.") arg))
948              ((symbolp arg)              ((symbolp arg)
949               (push arg other-args))               (push arg other-args))
950              ((and (listp arg) (symbolp (car arg)))              ((and (listp arg) (symbolp (car arg)))
951               (push (car arg) other-args))               (push (car arg) other-args))
952              (t (error "Illegal stuff in lambda list of Define-Modify-Macro."))))              (t (error (intl:gettext "Illegal stuff in lambda list of Define-Modify-Macro.")))))
953      (setq other-args (nreverse other-args))      (setq other-args (nreverse other-args))
954      `(defmacro ,name (,reference ,@lambda-list &environment ,env)      `(defmacro ,name (,reference ,@lambda-list &environment ,env)
955         ,doc-string         ,doc-string
# Line 966  Line 1055 
1055            (push (list (car d) (car v)) let-list)))))            (push (list (car d) (car v)) let-list)))))
1056    
1057    
1058  (define-modify-macro incf (&optional (delta 1)) +  ;;; we can't use DEFINE-MODIFY-MACRO because of ANSI 5.1.3
1059    "The first argument is some location holding a number.  This number is  (defmacro incf (place &optional (delta 1) &environment env)
1060    incremented by the second argument, DELTA, which defaults to 1.")    "The first argument is some location holding a number. This number is
1061      incremented by the second argument, DELTA, which defaults to 1."
1062      (multiple-value-bind (dummies vals newval setter getter)
1063  (define-modify-macro decf (&optional (delta 1)) -        (get-setf-method place env)
1064    "The first argument is some location holding a number.  This number is      (let ((d (gensym)))
1065    decremented by the second argument, DELTA, which defaults to 1.")        `(let* (,@(mapcar #'list dummies vals)
1066                  (,d ,delta)
1067                  (,(car newval) (+ ,getter ,d)))
1068             ,setter))))
1069    
1070    (defmacro decf (place &optional (delta 1) &environment env)
1071      "The first argument is some location holding a number. This number is
1072      decremented by the second argument, DELTA, which defaults to 1."
1073      (multiple-value-bind (dummies vals newval setter getter)
1074          (get-setf-method place env)
1075        (let ((d (gensym)))
1076          `(let* (,@(mapcar #'list dummies vals)
1077                  (,d ,delta)
1078                  (,(car newval) (- ,getter ,d)))
1079             ,setter))))
1080    
1081  (defmacro remf (place indicator &environment env)  (defmacro remf (place indicator &environment env)
1082    "Place may be any place expression acceptable to SETF, and is expected    "Place may be any place expression acceptable to SETF, and is expected
# Line 990  Line 1092 
1092            (local1 (gensym))            (local1 (gensym))
1093            (local2 (gensym)))            (local2 (gensym)))
1094           ((null d)           ((null d)
1095            (push (list (car newval) getter) let-list)            ;; See ANSI 5.1.3 for why we do out-of-order evaluation
1096            (push (list ind-temp indicator) let-list)            (push (list ind-temp indicator) let-list)
1097              (push (list (car newval) getter) let-list)
1098            `(let* ,(nreverse let-list)            `(let* ,(nreverse let-list)
1099               (do ((,local1 ,(car newval) (cddr ,local1))               (do ((,local1 ,(car newval) (cddr ,local1))
1100                    (,local2 nil ,local1))                    (,local2 nil ,local1))
1101                   ((atom ,local1) nil)                   ((atom ,local1) nil)
1102                 (cond ((atom (cdr ,local1))                 (cond ((atom (cdr ,local1))
1103                        (error "Odd-length property list in REMF."))                        (error (intl:gettext "Odd-length property list in REMF.")))
1104                       ((eq (car ,local1) ,ind-temp)                       ((eq (car ,local1) ,ind-temp)
1105                        (cond (,local2                        (cond (,local2
1106                               (rplacd (cdr ,local2) (cddr ,local1))                               (rplacd (cdr ,local2) (cddr ,local1))
# Line 1081  Line 1184 
1184  (defsetf sap-ref-sap %set-sap-ref-sap)  (defsetf sap-ref-sap %set-sap-ref-sap)
1185  (defsetf sap-ref-single %set-sap-ref-single)  (defsetf sap-ref-single %set-sap-ref-single)
1186  (defsetf sap-ref-double %set-sap-ref-double)  (defsetf sap-ref-double %set-sap-ref-double)
1187  #+long-float  #+(or x86 long-float)
1188  (defsetf sap-ref-long %set-sap-ref-long)  (defsetf sap-ref-long %set-sap-ref-long)
1189    
1190  (define-setf-expander getf (place prop &optional default &environment env)  (define-setf-expander getf (place prop &optional default &environment env)
# Line 1135  Line 1238 
1238                 (= (list-length function) 2)                 (= (list-length function) 2)
1239                 (eq (first function) 'function)                 (eq (first function) 'function)
1240                 (symbolp (second function)))                 (symbolp (second function)))
1241      (error "Setf of Apply is only defined for function args like #'symbol."))      (error (intl:gettext "Setf of Apply is only defined for function args like #'symbol.")))
1242    (let ((function (second function))    (let ((function (second function))
1243          (new-var (gensym))          (new-var (gensym))
1244          (vars nil))          (vars nil))
# Line 1212  Line 1315 
1315        (dolist (place places)        (dolist (place places)
1316          (multiple-value-bind (dummies vals newval setter getter)          (multiple-value-bind (dummies vals newval setter getter)
1317              (get-setf-expansion place env)              (get-setf-expansion place env)
1318            (setf all-dummies (append all-dummies dummies))            ;; ANSI CL 5.1.2.3 explains that extra places are set to
1319            (setf all-vals (append all-vals vals))            ;; nil.
1320            (setf newvals (append newvals newval))            (setf all-dummies (append all-dummies dummies (cdr newval)))
1321              (setf all-vals (append all-vals vals
1322                                     (mapcar (constantly nil) (cdr newval))))
1323              (setf newvals (append newvals (list (car newval))))
1324            (setters setter)            (setters setter)
1325            (getters getter)))            (getters getter)))
1326        (values all-dummies all-vals newvals        (values all-dummies all-vals newvals
# Line 1248  Line 1354 
1354            (case (first case-list) (first case-list)))            (case (first case-list) (first case-list)))
1355           ((null case-list))           ((null case-list))
1356        (cond ((atom case)        (cond ((atom case)
1357               (error "~S -- Bad clause in ~S." case name))               (error (intl:gettext "~S -- Bad clause in ~S.") case name))
1358              ((and (not allow-otherwise)              ((and (not allow-otherwise)
                   (null (cdr case-list))  
1359                    (memq (car case) '(t otherwise)))                    (memq (car case) '(t otherwise)))
1360               ;; The CLHS says OTHERWISE clause is an OTHERWISE clause               (cond ((null (cdr case-list))
1361               ;; only if it's the last case.  Otherwise, it's just a                      ;; The CLHS says OTHERWISE clause is an OTHERWISE clause
1362               ;; normal clause.                      ;; only if it's the last case.  Otherwise, it's just a
1363               (if errorp                      ;; normal clause.
1364                   (error "No default clause allowed in ~S: ~S" name case)                      (if errorp
1365                   (push `(t nil ,@(rest case)) clauses)))                          (error (intl:gettext "No default clause allowed in ~S: ~S") name case)
1366                            (push `(t nil ,@(rest case)) clauses)))
1367                       ((and (eq name 'case))
1368                        (error (intl:gettext "T and OTHERWISE may not be used as key designators for ~A") name))
1369                       ((eq (first case) t)
1370                        ;; The key T is normal clause, because it's not
1371                        ;; the last clause.
1372                        (push (first case) keys)
1373                        (push `((,test ,keyform-value
1374                                ',(first case)) nil ,@(rest case)) clauses))))
1375              ((and multi-p (listp (first case)))              ((and multi-p (listp (first case)))
1376               (setf keys (append (first case) keys))               (setf keys (append (first case) keys))
1377               (push `((or ,@(mapcar #'(lambda (key)               (push `((or ,@(mapcar #'(lambda (key)
# Line 1268  Line 1382 
1382              (t              (t
1383               (when (and allow-otherwise               (when (and allow-otherwise
1384                          (memq (car case) '(t otherwise)))                          (memq (car case) '(t otherwise)))
1385                 (warn "Bad style to use T or OTHERWISE in ECASE or CCASE"))                 (warn (intl:gettext "Bad style to use T or OTHERWISE in ECASE or CCASE")))
1386               (push (first case) keys)               (push (first case) keys)
1387               (push `((,test ,keyform-value               (push `((,test ,keyform-value
1388                              ',(first case)) nil ,@(rest case)) clauses))))                              ',(first case)) nil ,@(rest case)) clauses))))
# Line 1324  Line 1438 
1438               :possibilities keys)               :possibilities keys)
1439      (store-value (value)      (store-value (value)
1440        :report (lambda (stream)        :report (lambda (stream)
1441                  (format stream "Supply a new value for ~S." keyform))                  (format stream (intl:gettext "Supply a new value for ~S.") keyform))
1442        :interactive read-evaluated-form        :interactive read-evaluated-form
1443        value)))        value)))
1444    
1445    
1446  (defmacro case (keyform &body cases)  (defmacro case (keyform &body cases)
1447    "CASE Keyform {({(Key*) | Key} Form*)}*    "CASE Keyform {({(Key*) | Key} Form*)}*
1448    Evaluates the Forms in the first clause with a Key EQL to the value of    Evaluates the Forms in the first clause with a Key EQL to the value
1449    Keyform.  If a singleton key is T then the clause is a default clause."    of Keyform.  If a singleton key is T or Otherwise then the clause is
1450      a default clause."
1451    (case-body 'case keyform cases t 'eql nil nil))    (case-body 'case keyform cases t 'eql nil nil))
1452    
1453  (defmacro ccase (keyform &body cases)  (defmacro ccase (keyform &body cases)
# Line 1350  Line 1465 
1465    
1466  (defmacro typecase (keyform &body cases)  (defmacro typecase (keyform &body cases)
1467    "TYPECASE Keyform {(Type Form*)}*    "TYPECASE Keyform {(Type Form*)}*
1468    Evaluates the Forms in the first clause for which TYPEP of Keyform and Type    Evaluates the Forms in the first clause for which TYPEP of Keyform
1469    is true."    and Type is true.  If a singleton key is T or Otherwise then the
1470      clause is a default clause."
1471    (case-body 'typecase keyform cases nil 'typep nil nil))    (case-body 'typecase keyform cases nil 'typep nil nil))
1472    
1473  (defmacro ctypecase (keyform &body cases)  (defmacro ctypecase (keyform &body cases)
# Line 1391  Line 1507 
1507                     datum arguments                     datum arguments
1508                     'simple-error 'error)                     'simple-error 'error)
1509                    (make-condition 'simple-error                    (make-condition 'simple-error
1510                                    :format-control "The assertion ~S failed."                                    :format-control (intl:gettext "The assertion ~S failed.")
1511                                    :format-arguments (list assertion)))))                                    :format-arguments (list assertion)))))
1512    (restart-case (error cond)    (restart-case (error cond)
1513      (continue ()      (continue ()
# Line 1400  Line 1516 
1516    
1517    
1518  (defun assert-report (names stream)  (defun assert-report (names stream)
1519    (format stream "Retry assertion")    (format stream (intl:gettext "Retry assertion"))
1520    (if names    (if names
1521        (format stream " with new value~P for ~{~S~^, ~}."        (format stream (intl:ngettext " with new value for ~{~S~^, ~}."
1522                (length names) names)                                      " with new values for ~{~S~^, ~}."
1523                                        (length names))
1524                  names)
1525        (format stream ".")))        (format stream ".")))
1526    
1527  (defun assert-prompt (name value)  (defun assert-prompt (name value)
1528    (cond ((y-or-n-p "The old value of ~S is ~S.~    (cond ((y-or-n-p (intl:gettext "The old value of ~S is ~S.~
1529                    ~%Do you want to supply a new value? "                    ~%Do you want to supply a new value? ")
1530                     name value)                     name value)
1531           (format *query-io* "~&Type a form to be evaluated:~%")           (format *query-io* (intl:gettext "~&Type a form to be evaluated:~%"))
1532           (flet ((read-it () (eval (read *query-io*))))           (flet ((read-it () (eval (read *query-io*))))
1533             (if (symbolp name) ;help user debug lexical variables             (if (symbolp name) ;help user debug lexical variables
1534                 (progv (list name) (list value) (read-it))                 (progv (list name) (list value) (read-it))
# Line 1440  Line 1558 
1558  (defun check-type-error (place place-value type type-string)  (defun check-type-error (place place-value type type-string)
1559    (let ((cond (if type-string    (let ((cond (if type-string
1560                    (make-condition 'simple-type-error                    (make-condition 'simple-type-error
1561                                    :datum place :expected-type type                                    :datum place-value :expected-type type
1562                                    :format-control                                    :format-control
1563                                    "The value of ~S is ~S, which is not ~A."                                    (intl:gettext "The value of ~S is ~S, which is not ~A.")
1564                                    :format-arguments                                    :format-arguments
1565                                    (list place place-value type-string))                                    (list place place-value type-string))
1566                    (make-condition 'simple-type-error                    (make-condition 'simple-type-error
1567                                    :datum place :expected-type type                                    :datum place-value :expected-type type
1568                                    :format-control                                    :format-control
1569                            "The value of ~S is ~S, which is not of type ~S."                                    (intl:gettext "The value of ~S is ~S, which is not of type ~S.")
1570                                    :format-arguments                                    :format-arguments
1571                                    (list place place-value type)))))                                    (list place place-value type)))))
1572      (restart-case (error cond)      (restart-case (error cond)
1573        (store-value (value)        (store-value (value)
1574          :report (lambda (stream)          :report (lambda (stream)
1575                    (format stream "Supply a new value of ~S."                    (format stream (intl:gettext "Supply a new value of ~S.")
1576                            place))                            place))
1577          :interactive read-evaluated-form          :interactive read-evaluated-form
1578          value))))          value))))
# Line 1464  Line 1582 
1582  ;;; and by CHECK-TYPE.  ;;; and by CHECK-TYPE.
1583  ;;;  ;;;
1584  (defun read-evaluated-form ()  (defun read-evaluated-form ()
1585    (format *query-io* "~&Type a form to be evaluated:~%")    (format *query-io* (intl:gettext "~&Type a form to be evaluated:~%"))
1586    (list (eval (read *query-io*))))    (list (eval (read *query-io*))))
1587    
1588    
1589  ;;;; With-XXX  ;;;; With-XXX
1590  (defmacro with-open-file ((var &rest open-args) &body (forms decls))  (defmacro with-open-file ((var filespec &rest open-args) &parse-body (forms decls))
1591    "Bindspec is of the form (Stream File-Name . Options).  The file whose    "The file whose name is Filespec is opened using the Open-args and
1592     name is File-Name is opened using the Options and bound to the variable    bound to the variable Var. If the call to open is unsuccessful, the
1593     Stream. If the call to open is unsuccessful, the forms are not    forms are not evaluated.  The Forms are executed, and when they
1594     evaluated.  The Forms are executed, and when they    terminate, normally or otherwise, the file is closed."
    terminate, normally or otherwise, the file is closed."  
1595    (let ((abortp (gensym)))    (let ((abortp (gensym)))
1596      `(let ((,var (open ,@open-args))      `(let ((,var (open ,filespec ,@open-args))
1597             (,abortp t))             (,abortp t))
1598         ,@decls         ,@decls
1599         (unwind-protect         (unwind-protect
1600             (multiple-value-prog1              (multiple-value-prog1
1601                 (progn ,@forms)                  (progn ,@forms)
1602               (setq ,abortp nil))                (setq ,abortp nil))
1603           (when ,var           (when ,var
1604             (close ,var :abort ,abortp))))))             (close ,var :abort ,abortp))))))
1605    
1606    
1607  (defmacro with-open-stream ((var stream) &body (forms decls))  (defmacro with-open-stream ((var stream) &parse-body (forms decls))
1608    "The form stream should evaluate to a stream.  VAR is bound    "The form stream should evaluate to a stream.  VAR is bound
1609     to the stream and the forms are evaluated as an implicit     to the stream and the forms are evaluated as an implicit
1610     progn.  The stream is closed upon exit."     progn.  The stream is closed upon exit."
# Line 1497  Line 1614 
1614         ,@decls         ,@decls
1615         (unwind-protect         (unwind-protect
1616           (multiple-value-prog1           (multiple-value-prog1
1617            (progn ,@forms)              (progn ,@forms)
1618            (setq ,abortp nil))            (setq ,abortp nil))
1619           (when ,var           (when ,var
1620             (close ,var :abort ,abortp))))))             (close ,var :abort ,abortp))))))
1621    
1622    
1623  (defmacro with-input-from-string ((var string &key index start end) &body (forms decls))  (defmacro with-input-from-string ((var string &key index start end)
1624                                      &parse-body (forms decls))
1625    "Binds the Var to an input stream that returns characters from String and    "Binds the Var to an input stream that returns characters from String and
1626    executes the body.  See manual for details."    executes the body.  See manual for details."
1627    ;; The once-only inhibits compiler note for unreachable code when 'end' is true.    ;; The once-only inhibits compiler note for unreachable code when 'end' is true.
# Line 1519  Line 1637 
1637                      `(make-string-input-stream ,string ,(or start 0) ,end)))))                      `(make-string-input-stream ,string ,(or start 0) ,end)))))
1638         ,@decls         ,@decls
1639         (unwind-protect         (unwind-protect
1640             (progn ,@forms)              (multiple-value-prog1
1641           (close ,var)                  (progn ,@forms)
1642           ,@(if index `((setf ,index (string-input-stream-current ,var))))))))                ,@(when index
1643                       `((setf ,index (string-input-stream-current ,var)))))
1644             (close ,var)))))
1645    
1646    
1647  (defmacro with-output-to-string ((var &optional string) &body (forms decls))  (defmacro with-output-to-string ((var &optional string &key element-type)
1648                                     &parse-body (forms decls))
1649    "If STRING is specified, it must be a string with a fill pointer;    "If STRING is specified, it must be a string with a fill pointer;
1650     the output is incrementally appended to the string (as if by use of     the output is incrementally appended to the string (as if by use of
1651     VECTOR-PUSH-EXTEND)."     VECTOR-PUSH-EXTEND)."
1652      (declare (ignore element-type))
1653    (if string    (if string
1654        `(let ((,var (make-fill-pointer-output-stream ,string)))        `(let ((,var (make-fill-pointer-output-stream ,string)))
1655           ,@decls           ,@decls
# Line 1544  Line 1666 
1666    
1667  ;;;; Iteration macros:  ;;;; Iteration macros:
1668    
1669    ;; Helper for dotimes.  Extract any declarations for the dotimes
1670    ;; counter and create a similar declaration for our dummy loop
1671    ;; counter.  Skip over special declarations, though, because we don't
1672    ;; want to make the dummy counter special.
1673    ;;
1674    ;; Returns two values:
1675    ;; 1.  Set of declarations for the dotimes loop counter that would be
1676    ;;     suitable for use in the result-form of the loop,
1677    ;; 2.  Declarations suitable for the dummy loop counter.
1678    (defun dotimes-extract-var-decls (var counter count decls)
1679      (let (var-decls counter-decls)
1680        (dolist (decl decls)
1681          (dolist (d (cdr decl))
1682            (when (member var (cdr d))
1683              (cond ((eq (car d) 'type)
1684                     (push `(type ,(second d) ,var) var-decls)
1685                     (push `(type ,(second d) ,counter) counter-decls))
1686                    ((eq (car d) 'special)
1687                     ;; Declare var special, but not the counter
1688                     (push `(,(car d) ,var) var-decls))
1689                    (t
1690                     (push `(,(car d) ,var) var-decls)
1691                     (push `(,(car d) ,counter) counter-decls))))))
1692        (unless counter-decls
1693          (setf counter-decls (if (numberp count)
1694                                  `((type (integer 0 ,count) ,counter))
1695                                  `((type unsigned-byte ,counter)))))
1696        (values (if var-decls
1697                    `((declare ,@(nreverse var-decls)))
1698                    nil)
1699                `((declare ,@(nreverse counter-decls))))))
1700    
1701    
1702    ;;; Make sure we iterate the given number of times, independent of
1703    ;;; what the body might do to the index variable.  We do this by
1704    ;;; repeatedly binding the var in the body and also in the result
1705    ;;; form.  We also spuriously reference the var in case the body or
1706    ;;; result form don't reference the var either.  (Mostly modeled on
1707    ;;; the dolist macro below.)
1708  (defmacro dotimes ((var count &optional (result nil)) &body body)  (defmacro dotimes ((var count &optional (result nil)) &body body)
1709    (cond ((numberp count)    (let ((count-var (gensym "CTR-")))
1710           `(do ((,var 0 (1+ ,var)))      (multiple-value-bind (forms decls)
1711                ((>= ,var ,count) ,result)          (parse-body body nil nil)
1712              (declare (type (integer 0 ,count) ,var))        (multiple-value-bind (var-decls ctr-decls)
1713              ,@body))            (dotimes-extract-var-decls var count-var count decls)
1714          (t (let ((v1 (gensym)))          (cond ((numberp count)
1715               `(do ((,var 0 (1+ ,var)) (,v1 ,count))                 `(do ((,count-var 0 (1+ ,count-var)))
1716                    ((>= ,var ,v1) ,result)                      ((>= ,count-var ,count)
1717                  (declare (type unsigned-byte ,var))                       (let ((,var ,count-var))
1718                  ,@body)))))                         ,@var-decls
1719                           ,var
1720                           ,result))
1721                      ,@ctr-decls
1722                      (let ((,var ,count-var))
1723                        ,@decls
1724                        ,var
1725                        (tagbody
1726                           ,@forms))))
1727                  (t (let ((v1 (gensym)))
1728                       `(do ((,count-var 0 (1+ ,count-var))
1729                             (,v1 ,count))
1730                            ((>= ,count-var ,v1)
1731                             (let ((,var ,count-var))
1732                               ,@var-decls
1733                               ,var
1734                               ,result))
1735                          ,@ctr-decls
1736                          (let ((,var ,count-var))
1737                            ,@decls
1738                            ,var
1739                            (tagbody
1740                               ,@forms))))))))))
1741    
1742    
1743  ;;; We repeatedly bind the var instead of setting it so that we never give the  ;;; We repeatedly bind the var instead of setting it so that we never give the
# Line 1582  Line 1765 
1765               ,@forms))))))               ,@forms))))))
1766    
1767    
1768  (defmacro do (varlist endlist &body (body decls))  (defmacro do (varlist endlist &parse-body (body decls))
1769    "DO ({(Var [Init] [Step])}*) (Test Exit-Form*) Declaration* Form*    "DO ({(Var [Init] [Step])}*) (Test Exit-Form*) Declaration* Form*
1770    Iteration construct.  Each Var is initialized in parallel to the value of the    Iteration construct.  Each Var is initialized in parallel to the value of the
1771    specified Init form.  On subsequent iterations, the Vars are assigned the    specified Init form.  On subsequent iterations, the Vars are assigned the
# Line 1595  Line 1778 
1778    (do-do-body varlist endlist body decls 'let 'psetq 'do nil))    (do-do-body varlist endlist body decls 'let 'psetq 'do nil))
1779    
1780    
1781  (defmacro do* (varlist endlist &body (body decls))  (defmacro do* (varlist endlist &parse-body (body decls))
1782    "DO* ({(Var [Init] [Step])}*) (Test Exit-Form*) Declaration* Form*    "DO* ({(Var [Init] [Step])}*) (Test Exit-Form*) Declaration* Form*
1783    Iteration construct.  Each Var is initialized sequentially (like LET*) to the    Iteration construct.  Each Var is initialized sequentially (like LET*) to the
1784    value of the specified Init form.  On subsequent iterations, the Vars are    value of the specified Init form.  On subsequent iterations, the Vars are
# Line 1621  Line 1804 
1804        ((endp pair) `(psetf ,@pairs))        ((endp pair) `(psetf ,@pairs))
1805      (unless (symbolp (car pair))      (unless (symbolp (car pair))
1806        (error 'simple-program-error        (error 'simple-program-error
1807               :format-control "variable ~S in PSETQ is not a SYMBOL"               :format-control (intl:gettext "variable ~S in PSETQ is not a SYMBOL")
1808               :format-arguments (list (car pair))))))               :format-arguments (list (car pair))))))
1809    
1810    
# Line 1673  Line 1856 
1856                (:global (member parent '(defun defmacro function)))                (:global (member parent '(defun defmacro function)))
1857                (:local (member parent '(labels flet)))                (:local (member parent '(labels flet)))
1858                (t                (t
1859                 (error "Unknown declaration context: ~S." context))))                 (error (intl:gettext "Unknown declaration context: ~S.") context))))
1860            (case (first context)            (case (first context)
1861              (:or              (:or
1862               (loop for x in (rest context)               (loop for x in (rest context)
# Line 1694  Line 1877 
1877                    (loop for x in (rest context)                    (loop for x in (rest context)
1878                          thereis (eq (find-package (string x)) package))))                          thereis (eq (find-package (string x)) package))))
1879              (t              (t
1880               (error "Unknown declaration context: ~S." context)))))))               (error (intl:gettext "Unknown declaration context: ~S.") context)))))))
1881    
1882    
1883  ;;; PROCESS-CONTEXT-DECLARATIONS  --  Internal  ;;; PROCESS-CONTEXT-DECLARATIONS  --  Internal
# Line 1707  Line 1890 
1890     (mapcar     (mapcar
1891      #'(lambda (decl)      #'(lambda (decl)
1892          (unless (>= (length decl) 2)          (unless (>= (length decl) 2)
1893            (error "Context declaration spec should have context and at ~            (error (intl:gettext "Context declaration spec should have context and at ~
1894            least one DECLARE form:~%  ~S" decl))            least one DECLARE form:~%  ~S") decl))
1895          #'(lambda (name parent)          #'(lambda (name parent)
1896              (when (evaluate-declaration-context (first decl) name parent)              (when (evaluate-declaration-context (first decl) name parent)
1897                (rest decl))))                (rest decl))))
# Line 1781  Line 1964 
1964          (n-fun (gensym))          (n-fun (gensym))
1965          (n-abort-p (gensym)))          (n-abort-p (gensym)))
1966      (when (oddp (length options))      (when (oddp (length options))
1967        (error "Odd number of key/value pairs: ~S." options))        (error (intl:gettext "Odd number of key/value pairs: ~S.") options))
1968      (do ((opt options (cddr opt)))      (do ((opt options (cddr opt)))
1969          ((null opt))          ((null opt))
1970        (case (first opt)        (case (first opt)
# Line 1794  Line 1977 
1977          (:context-declarations          (:context-declarations
1978           (setq context-declarations (second opt)))           (setq context-declarations (second opt)))
1979          (t          (t
1980           (warn "Ignoring unknown option: ~S." (first opt)))))           (warn (intl:gettext "Ignoring unknown option: ~S.") (first opt)))))
1981    
1982      `(flet ((,n-fun ()      `(flet ((,n-fun ()
1983                (let (,@(when optimize                (let (,@(when optimize
# Line 1822  Line 2005 
2005               (handler-bind ((c::parse-unknown-type               (handler-bind ((c::parse-unknown-type
2006                               #'(lambda (c)                               #'(lambda (c)
2007                                   (c::note-undefined-reference                                   (c::note-undefined-reference
2008                                    (c::parse-unknown-type-specifier c)                                    (kernel:parse-unknown-type-specifier c)
2009                                    :type))))                                    :type))))
2010                 (unwind-protect                 (unwind-protect
2011                     (multiple-value-prog1                     (multiple-value-prog1

Legend:
Removed from v.1.90.2.1  
changed lines
  Added in v.1.120

  ViewVC Help
Powered by ViewVC 1.1.5