Re: Configuring read and write for syntax extensions Marc Nieper-Wißkirchen 16 Aug 2020 12:25 UTC

Am So., 16. Aug. 2020 um 14:06 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:

> And if an output port knows its settings, we can have a
> `write-port-settings` (better name welcome) procedure that writes the
> corresponding #! directives to the output port. Then you can easily
> write files that self-describe what syntax they are using.

To mimic the behavior of "read", I wouldn't add a procedure that
writes the directives explicitly but would rule that it is the
responsibility of the "write" procedure to output these directives
whenever it observes a change in the current flags.

> We should probably use a more specific name like `set-syntax-flag!`.
> Port flags could be something that also apply to byte ports, e.g.
> blocking vs non-blocking.

That's a good point. "Textual" could also appear in the name of such
setter. I would propose to have a general mechanism, which rules that
each textual port has a dictionary (an alist?) mapping symbols to
datums (mostly #t or #f). Read and write have to be aware of these
settings (and we need a "#!" syntax for settings with non-boolean
values, e.g. number precision or default base). SRFIs like SRFI 207
could then hook into this general API.