Switch to write-unreadable?
Lassi Kortela 17 Dec 2022 13:40 UTC
I tried to play around with the #< syntax some more. Still can't find
anything that looks good and could be parsed reliably. It makes sense
for RnRS to cause a syntax error upon encountering #< but beyond that,
there isn't anything to say about it. I can't dedicate a whole SRFI to
saying one sentence.
Given that Shiro and I are the only ones so far who like the proposed
#?datum syntax, I'll hold off on proposing it in this SRFI and retarget
the SRFI to specify a `write-unreadable` procedure instead.
The idea is that (write-unreadable list [port]) writes a representation
of an unreadable object to the given port. It's given a list with one or
more items. The first item is a symbol indicating what type of object is
being represented; the rest can be arbitrary objects giving extra detail.
The lexical syntax to write is implementation-defined; can be #<foo
...>, #[foo ...], #?(foo ...), or something else.
In the future, some Scheme implementations will probably be able to
write more than one kind of syntax. Syntax settings should probably be
associated with port objects. So (write foo some-port) and
(write-unreadable foo some-port) would both use the appropriate syntax
for some-port.
Does this sound reasonable, given the circumstances, or should I do
something else?