unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#24816: Bug in (rnrs io ports) procedure open-string-output-port
@ 2016-10-29 10:29 Freja Nordsiek
  2017-03-01 13:26 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Freja Nordsiek @ 2016-10-29 10:29 UTC (permalink / raw)
  To: 24816

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





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

* bug#24816: Bug in (rnrs io ports) procedure open-string-output-port
  2016-10-29 10:29 bug#24816: Bug in (rnrs io ports) procedure open-string-output-port Freja Nordsiek
@ 2017-03-01 13:26 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2017-03-01 13:26 UTC (permalink / raw)
  To: Freja Nordsiek; +Cc: 24816-done

On Sat 29 Oct 2016 12:29, Freja Nordsiek <fnordsie@gmail.com> 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





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

end of thread, other threads:[~2017-03-01 13:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-29 10:29 bug#24816: Bug in (rnrs io ports) procedure open-string-output-port Freja Nordsiek
2017-03-01 13:26 ` Andy Wingo

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