Changeset 459


Ignore:
Timestamp:
Feb 2, 2004, 8:06:10 AM (21 years ago)
Author:
Gary Byers
Message:

Bryan O'Connor's fix to WITH-SIMPLE-RESTART. LET-GLOBALLY moved here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/macros.lisp

    r445 r459  
    424424      (setq format-string `#'(lambda (,stream) (format ,stream ,format-string ,@format-args)))))
    425425  `(let* ((,temp (%cons-restart ',restart-name
    426                                 nil
     426                                #'(lambda () (values nil t))
    427427                                ,format-string
    428428                                nil
     
    28672867    `(eval-when (:compile-toplevel :load-toplevel :execute)
    28682868       ,@(nreverse results))))
     2869
     2870
     2871;;; This does something like special binding, but the "bindings" established
     2872;;; aren't thread-specific.
     2873
     2874(defmacro let-globally ((&rest vars) &body body &environment env)
     2875  (multiple-value-bind (body decls) (parse-body body env)
     2876    (let* ((initforms nil)
     2877           (psetform nil)
     2878           (specvars nil)
     2879           (restoreform nil))
     2880      (flet ((pair-name-value (p)
     2881               (if (atom p)
     2882                 (values (require-global-symbol p env) nil)
     2883                 (if (and (consp (%cdr p)) (null (%cddr p)))
     2884                   (values (require-global-symbol (%car p) env) (%cadr p))
     2885                   (error "Invalid variable initialization form : ~s")))))
     2886        (declare (inline pair-name-value))
     2887        (dolist (v vars)
     2888          (let* ((oldval (gensym))
     2889                 (newval (gensym)))
     2890            (multiple-value-bind (var valueform) (pair-name-value v)
     2891              (push var specvars)
     2892              (push var restoreform)
     2893              (push oldval restoreform)
     2894              (push `(,oldval (uvref ',var #.ppc32::symbol.vcell-cell)) initforms)
     2895              (push `(,newval ,valueform) initforms)
     2896              (push var psetform)
     2897              (push newval psetform))))
     2898        `(let ,(nreverse initforms)
     2899           ,@decls
     2900           (locally (declare (special ,@(nreverse specvars)))
     2901             (unwind-protect
     2902               (progn (psetq ,@(nreverse psetform)) ,@body)
     2903               (psetq ,@(nreverse restoreform)))))))))
Note: See TracChangeset for help on using the changeset viewer.