[R6RS] write/read or read/write invariance
dyb at cs.indiana.edu
dyb at cs.indiana.edu
Tue May 16 00:34:11 EDT 2006
> 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))
Okay, so if we write out something that qualifies as a datum, it reads
back in as the same datum. But earlier you told Anton that:
The word "datum" means one of the external representations
that are generated by the nonterminal <datum> in the formal
syntax of Scheme. Since the value returned by (unspecified)
has no external representation (aside from implementation-
specific extensions), it is not a datum.
So is datum an external representation (as the quoted text says) or a type
of object that has an external representation (as your datum? predicate
implies)? If the latter, is a list or vector that contains an element
that is something other than a datum really a datum? Similarly, is a list
or vector x that contains an element eq? to x really a datum? I notice
you left out improper lists, like (a . b)---was this an oversight or do
only proper lists qualify?
I suspect that you meant to include pairs, to exclude lists or vectors
that contain an element that is not a datum, and to exclude cyclic
structures in general (since we opted not to include a syntax for cyclic
structures). Thus, not every list or vector we construct is a datum. Why
then must every symbol we construct be a datum? If we're free to say what
datum? means on our way to "write/read invariance", can't we say that if
sym is a symbol, then (datum? sym) is true iff (symbol->string sym) can
be parsed via the R5RS grammar for forming symbols? I'm not necessarily
advocating this, just trying to figure out the principle, if any, behind
"write/read invariance".
> > 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.
I don't see where it requires the use of any particular external
representation. Will this be specified elsewhere in the report?
> > 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;
> ...
> Oops. I wrote:
>
> > > What will the file foo contain?
> >
> > \31;\32;\33;\34;\35;
>
> The file's contents should instead be:
>
> \x31;\x32;\x33;\x34;\x35;
Could this be
\x31;2345
instead? Is one form encouraged over the other? Could it be
1\x32;345
instead? (I assume not.)
> By the way, in the current draft of the Unicode SRFI, the
> third bullet item under "Symbol Lexical Syntax" is stated
> incorrectly. I'd guess that was the source of Kent's
> question.
Not really, but thanks for fixing it.
The third bullet item still isn't clear, however, since it says only what
happens if a slash appears in a symbol and not where slashes can appear.
One possibility is that \x<x>...<x>; counts as an <initial>, no
matter what character it represents.
Kent
More information about the R6RS
mailing list