[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Thien-Thi Nguyen
Subject: with-excursion-function
Date: Fri, 15 Jul 2005 17:59:44 +0200


the `with-excursion-function' macro seems to be bolted-on to module
(ice-9 calling).  here is how to use it:

(define a 42)
(define c 999)
(define (spew!) (write-line (list #:a a #:c c)))

 (a c) (lambda (ex)
         (ex (lambda ()
               (set! a 0)
               (set! c -1)

the call site seems to be rather convoluted, compared to:

(define-macro (save-bindings-excursion vars . body)
  (let ((saved-value-names (map (lambda ignored (gensym)) vars))
        (tmp-var-name (gensym))
        (swap-fn-name (gensym)))
    `(let ((,tmp-var-name #f)
           ,@(map list saved-value-names vars))
       (define (,swap-fn-name)
         ,@(apply append (map (lambda (n sn)
                                `((set! ,tmp-var-name ,n)
                                  (set! ,n ,sn)
                                  (set! ,sn ,tmp-var-name)))
                              vars saved-value-names)))
           (lambda () ,@body)

(save-bindings-excursion (a c)
  (set! a 0)
  (set! c -1)

so i wonder: can anyone show code that uses `with-excursion-function'?
google does not reveal any usage, and the ice-9 doc by Tom Lord ~1999
does not mention it, either.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]