/[guile]/guile/guile-core/ice-9/boot-9.scm
ViewVC logotype

Diff of /guile/guile-core/ice-9/boot-9.scm

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

revision 1.317 by kryde, Tue Aug 12 21:38:21 2003 UTC revision 1.318 by kryde, Sun Aug 17 00:36:04 2003 UTC
# Line 2554  Line 2554 
2554  ;;;  ;;;
2555    
2556  ;; The inner `do' loop avoids re-establishing a catch every iteration,  ;; The inner `do' loop avoids re-establishing a catch every iteration,
2557  ;; that's only necessary if continue is actually used.  ;; that's only necessary if continue is actually used.  A new key is
2558    ;; generated every time, so break and continue apply to their originating
2559    ;; `while' even when recursing.  `while-helper' is an easy way to keep the
2560    ;; `key' binding away from the cond and body code.
2561  ;;  ;;
2562  (define-macro (while cond . body)  (define-macro (while cond . body)
2563    (let ((key (make-symbol "while-key")))    (define (while-helper proc)
2564      `(,do ((break    ,(lambda () (throw key #t)))      (do ((key (make-symbol "while-key")))
2565             (continue ,(lambda () (throw key #f))))          ((catch key
2566           ((,catch (,quote ,key)                  (lambda ()
2567                    (,lambda ()                    (proc (lambda () (throw key #t))
2568                            (lambda () (throw key #f))))
2569                    (lambda (key arg) arg)))))
2570      `(,while-helper (,lambda (break continue)
2571                      (,do ()                      (,do ()
2572                          ((,not ,cond))                          ((,not ,cond))
2573                        ,@body)                        ,@body)
2574                      #t)                      #t)))
2575                    ,(lambda (key arg) arg))))))  
2576    
2577    
2578  ;;; {Module System Macros}  ;;; {Module System Macros}

Legend:
Removed from v.1.317  
changed lines
  Added in v.1.318

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26