GNU bug report logs - #14039
Bug in with-fluids semantics

Previous Next

Package: guile;

Reported by: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>

Date: Sat, 23 Mar 2013 10:51:01 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Israelsson Tampe <stefan.itampe <at> gmail.com>
To: Daniel Hartwig <mandyke <at> gmail.com>
Cc: 14039 <at> debbugs.gnu.org
Subject: bug#14039: Bug in with-fluids semantics
Date: Sat, 23 Mar 2013 16:41:15 +0100
I would expect
(k) to be the same. Otherwise fluids would not mix well with undo redo sematics.
But I do understand that people might have decided that it should work
like this.
and knowing the this semantic, one can fix the problem. If the
semantics is correct
I really can't find an example where it is useful though. Do you have
an example?

/Stefan

On Sat, Mar 23, 2013 at 3:51 PM, Daniel Hartwig <mandyke <at> gmail.com> wrote:
> On 23 March 2013 18:41, Stefan Israelsson Tampe <stefan.itampe <at> gmail.com> wrote:
>> 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
>>
>
> What values do you expect from successive calls to K?
>
>> 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.
>
> K captures S, a fluid, along with the dynamic extent.  There is only a
> single dynamic extent to which K resumes, and only one value
> associated to the fluid S within that.  Subsequent calls to K do not
> generate a new dynamic extent, so it makes sense that modifications to
> the fluids value persist.  This example behaives as expected according
> to my understanding of fluids.
>
> Am I missing something?




This bug report was last modified 12 years and 119 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.