[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
with-excursion-function
From: |
Thien-Thi Nguyen |
Subject: |
with-excursion-function |
Date: |
Fri, 15 Jul 2005 17:59:44 +0200 |
folks,
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)))
(with-excursion-function
(a c) (lambda (ex)
(ex (lambda ()
(spew!)
(set! a 0)
(set! c -1)
(spew!)))))
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)))
(dynamic-wind
,swap-fn-name
(lambda () ,@body)
,swap-fn-name))))
(save-bindings-excursion (a c)
(spew!)
(set! a 0)
(set! c -1)
(spew!))
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.
thi
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- with-excursion-function,
Thien-Thi Nguyen <=