Subject: bug#24816: closed (Re: bug#24816: Bug in (rnrs io ports) procedure open-string-output-port)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 01 Mar 2017 13:28:02 +0000

Your bug report

#24816: Bug in (rnrs io ports) procedure open-string-output-port

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
24816: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24816
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#24816: Bug in (rnrs io ports) procedure open-string-output-port
From: Andy Wingo <[email-masked]>
To: Freja Nordsiek <[email-masked]>
Cc: [email-masked]
Date: Wed, 01 Mar 2017 14:26:50 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On Sat 29 Oct 2016 12:29, Freja Nordsiek <[email-masked]> writes:

> The "open-string-output-port" procedure in (rnrs io ports) returns two
> values, a string port and a thunk that returns a string of the
> characters written to the port so far. In the R6RS standard documents,
> the reading procedure is destructive, in that it clears all the
> characters written to the port so far (though, it does not close it,
> so it can still be used). However, in Guile 2.1.4, the characters are
> not cleared and so running the thunk again immediately afterwards will
> produce the same output, which is a bug.

Thanks for the report; fixed in git.  Cheers :)

Andy

Subject: Bug in (rnrs io ports) procedure open-string-output-port
From: Freja Nordsiek <[email-masked]>
To: [email-masked]
Date: Sat, 29 Oct 2016 17:29:09 +0700
List-Id: <debbugs-submit.debbugs.gnu.org>

The "open-string-output-port" procedure in (rnrs io ports) returns two
values, a string port and a thunk that returns a string of the
characters written to the port so far. In the R6RS standard documents,
the reading procedure is destructive, in that it clears all the
characters written to the port so far (though, it does not close it,
so it can still be used). However, in Guile 2.1.4, the characters are
not cleared and so running the thunk again immediately afterwards will
produce the same output, which is a bug.

This can be tested running the following script

    (import (rnrs base (6))
            (rnrs io ports (6))
            (rnrs io simple (6)))

    (let-values (((p get-output) (open-string-output-port)))
      (display "hello" p)
      (flush-output-port p)
      (let ((out-first (get-output)))
        (let ((out-second (get-output)))
          (display (string-append "Follows R6RS: "
                                  (if (string=? out-first out-second)
                                      "no"
                                      "yes")))
          (newline)
          (display (string-append "out-first: " out-first))
          (newline)
          (display (string-append "out-second: " out-second))
          (newline))))

which produces the following output in guile

    Follows R6RS: no
    out-first: hello
    out-second: hello

when it should output

    Follows R6RS: yes
    out-first: hello
    out-second:

instead.

Freja Nordsiek