[R6RS] write/read or read/write invariance

William D Clinger will at ccs.neu.edu
Fri May 12 13:31:38 EDT 2006


Kent wrote:
> I think I may be confused about what is meant by write/read invariance (or
> read/write invariance, if that's what we want and there's a difference).

Yes, there is a difference, but I'm not sure which is
which.

> Can someone explain for me exactly what is intended

What is intended, I believe, is that for every input
port p

    [let [[x [read p]]
          [tmp "/tmp/foo"]]
      [define [datum? x]
        [or [boolean? x]
            [number? x]
            [char? x]
            [string? x]
            [symbol? x]
            [list? x]
            [vector? x]]]
      [if [datum? x]
          [equal? [begin [call-with-output-file tmp
                          [lambda [out] [write x out]]]
                         [call-with-input-file tmp read]]
                  x]
          #t]]

> and how (if) the
> current Unicode SRFI draft (i.e., the one committed to the repository)
> implements it?

It provides external representations for every character,
string, and symbol that can be expressed using Unicode
scalar values.

> In particular, should the following return #t (assuming that there are no
> I/O problems)?
> 
>   (let ([x (string->symbol "12345")])
>     (with-output-to-file "foo" (lambda () (write x)))
>     (eq? (with-input-from-file "foo" read) x))

Yes.

> What will the file foo contain?

\31;\32;\33;\34;\35;

We decided this was ugly enough to discourage programmers
from using such weird symbols in programs.  Now if only we
could get rid of the square brackets...

Will



More information about the R6RS mailing list