Re: Configuring read and write for syntax extensions
Lassi Kortela 16 Aug 2020 12:44 UTC
>> A port can be accessed from multiple threads, so it might be better to make port flags either port-and-thread-specific, or having (with-port-flag thunk) that locks the port.
>
> Thread-specific port flags would be wrong (this is also not true for
> the implicit "fold-case" flag of R7RS). If one thread switches the
> mode and writes some directive to a given port, the writer of the
> other thread needs to know that this directive is active on that port.
> Otherwise, the resulting data may be garbage.
Yes, each thread's syntax would be consistent but the output file's
syntax would be inconsistent. Well, if `write` automatically writes any
changed #! flags, then I guess consistency is maintained.
As a similar issue, one thread can seek the port and confuse another
thread's idea about the port position. It's sounds too difficult to
guard all port state against interfering threads.