unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* with-excursion-function
@ 2005-07-15 15:59 Thien-Thi Nguyen
  0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2005-07-15 15:59 UTC (permalink / raw)


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


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-15 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-15 15:59 with-excursion-function Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).