The principal domain of the write procedure are datum objects, which
possess a written representation. As long as one does not use write
outside this domain, nothing is inconsistent and write works as
intended (namely for textual exchange of datum objects).

That's the literal meaning of current editions of RnRS, but Scheme and Lisp don't stop there. It's clear that all implementations have unreadable objects and something must be done about writing them.

Raising an exception is one possibility, but that would be a pain in the REPL.

What is the precise definition of "self-consistent"?

I'm not aware of a precise definition. "Read-write invariance" comes close, but unreadable objects cannot have that property.

For example (write '("one" "two")) will output:

("one" "two")

whereas (display '("one" "two")) will output:

(one two)

The `write` representation consistently mirrors the structure of the object it was told to write. But the `display` representation is inconsistent with the original object: what was one string now looks to `read` like two symbols.

`display` is explicitly designed to act like that, but `write` is intended to produce structurally consistent lexical syntax. If `write` produces something like #<a b c> it looks like the three symbols `a` `b` and `c>`. That interpretation doesn't match the input (which was intended to be the three symbols a b c), even if the reader is aware of the `#<` prefix.

Reply via email to