0.8.10.60:
[sbcl.git] / src / code / early-extensions.lisp
index 81b6f7b..6a95f38 100644 (file)
 
 ;;; Iterate over the entries in a HASH-TABLE.
 (defmacro dohash ((key-var value-var table &optional result) &body body)
-  (multiple-value-bind (forms decls) (parse-body body nil)
+  (multiple-value-bind (forms decls) (parse-body body :doc-string-allowed nil)
     (let ((gen (gensym))
          (n-more (gensym)))
       `(with-hash-table-iterator (,gen ,table)
 (defun %failed-aver (expr-as-string)
   (bug "~@<failed AVER: ~2I~_~S~:>" expr-as-string))
 
-;;; We need a definition of BUG here for the host compiler to be able
-;;; to deal with BUGs in sbcl. This should never affect an end-user,
-;;; who will pick up the definition that signals a CONDITION of
-;;; condition-class BUG; however, this is not defined on the host
-;;; lisp, but for the target. SBCL developers sometimes trigger BUGs
-;;; in their efforts, and it is useful to get the details of the BUG
-;;; rather than an undefined function error. - CSR, 2002-04-12
-#+sb-xc-host
 (defun bug (format-control &rest format-arguments)
-  (error 'simple-error
-        :format-control "~@<  ~? ~:@_~?~:>"
-        :format-arguments `(,format-control
-                            ,format-arguments
-                            "~@<If you see this and are an SBCL ~
-developer, then it is probable that you have made a change to the ~
-system that has broken the ability for SBCL to compile, usually by ~
-removing an assumed invariant of the system, but sometimes by making ~
-an averrance that is violated (check your code!). If you are a user, ~
-please submit a bug report to the developers' mailing list, details of ~
-which can be found at <http://sbcl.sourceforge.net/>.~:@>"
-                            ())))
+  (error 'bug
+        :format-control format-control
+        :format-arguments format-arguments))
 
 (defmacro enforce-type (value type)
   (once-only ((value value))
@@ -1097,7 +1080,7 @@ which can be found at <http://sbcl.sourceforge.net/>.~:@>"
                (let ((it ,test)) (declare (ignorable it)),@body)
                (acond ,@rest))))))
 
-;;; (binding* ({(name initial-value [flag])}*) body)
+;;; (binding* ({(names initial-value [flag])}*) body)
 ;;; FLAG may be NIL or :EXIT-IF-NULL
 ;;;
 ;;; This form unites LET*, MULTIPLE-VALUE-BIND and AWHEN.
@@ -1115,7 +1098,15 @@ which can be found at <http://sbcl.sourceforge.net/>.~:@>"
                      (symbol
                       (values (list names) nil))
                      (list
-                      (values names nil)))
+                      (collect ((new-names) (ignorable))
+                        (dolist (name names)
+                          (when (eq name nil)
+                            (setq name (gensym))
+                            (ignorable name))
+                          (new-names name))
+                        (values (new-names)
+                                (when (ignorable)
+                                  `((declare (ignorable ,@(ignorable)))))))))
                  (setq form `(multiple-value-bind ,names
                                  ,initial-value
                                ,@declarations
@@ -1138,3 +1129,31 @@ which can be found at <http://sbcl.sourceforge.net/>.~:@>"
 (defun promise-ready-p (promise)
   (or (not (consp promise))
       (car promise)))
+\f
+;;; toplevel helper
+(defmacro with-rebound-io-syntax (&body body)
+  `(%with-rebound-io-syntax (lambda () ,@body)))
+
+(defun %with-rebound-io-syntax (function)
+  (declare (type function function))
+  (let ((*package* *package*)
+       (*print-array* *print-array*)
+       (*print-base* *print-base*)
+       (*print-case* *print-case*)
+       (*print-circle* *print-circle*)
+       (*print-escape* *print-escape*)
+       (*print-gensym* *print-gensym*)
+       (*print-length* *print-length*)
+       (*print-level* *print-level*)
+       (*print-lines* *print-lines*)
+       (*print-miser-width* *print-miser-width*)
+       (*print-pretty* *print-pretty*)
+       (*print-radix* *print-radix*)
+       (*print-readably* *print-readably*)
+       (*print-right-margin* *print-right-margin*)
+       (*read-base* *read-base*)
+       (*read-default-float-format* *read-default-float-format*)
+       (*read-eval* *read-eval*)
+       (*read-suppress* *read-suppress*)
+       (*readtable* *readtable*))
+    (funcall function)))