unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#14039: Bug in with-fluids semantics
@ 2013-03-23 10:41 Stefan Israelsson Tampe
  2013-03-23 14:51 ` Daniel Hartwig
  2013-03-23 19:07 ` Andy Wingo
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Israelsson Tampe @ 2013-03-23 10:41 UTC (permalink / raw)
  To: 14039

Consider this simple exmple with fluids and reodos via propmts,

(define (f x) 
  (let ((s (make-fluid 0))) 
     (with-fluids ((s 0)) 
        (let lp ((i 0)) 
           (cond ((>= i 100) (fluid-ref s)) 
                 ((= i 50) (abort-to-prompt 'tag) (lp (+ i 1))) 
                 (else (fluid-set! s (+ (fluid-ref s) i)) 
		       (lp (+ i 1))))))))

(define k (call-with-prompt 'tag (lambda () (f 1)) (lambda (k . l)
k)))

Then we will get in guile-2.0 pretty resent git version
scheme@(guile-user)> (k)
$1 = 4900
scheme@(guile-user)> (k)
$2 = 8575

The reason is that when the with-fluid returns normally it does a full
swap. It should only do half a swap e.g. restore the old value of the
fluid and not store the current which is of non use because it can not
be reached anymore and it contaminates the continuation k.

/Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-03-24 13:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-23 10:41 bug#14039: Bug in with-fluids semantics Stefan Israelsson Tampe
2013-03-23 14:51 ` Daniel Hartwig
2013-03-23 15:41   ` Stefan Israelsson Tampe
2013-03-23 17:58   ` Stefan Israelsson Tampe
2013-03-23 19:07 ` Andy Wingo
2013-03-23 19:44   ` Stefan Israelsson Tampe
2013-03-24 13:47   ` Stefan Israelsson Tampe

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).