[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Needed: per-port reader options

From: Mark H Weaver
Subject: Needed: per-port reader options
Date: Sat, 13 Oct 2012 14:51:36 -0400

I recently tried to implement reader directives, e.g.:

  #!fold-case     (from R7RS)
  #!no-fold-case  (from R7RS)
  #!curly-infix   (from SRFI-105)

However, I ran into a rather serious problem.  Guile's reader options
are global to the entire process, but clearly these reader directives
should affect only the port they are read from.  So we need to support
per-port reader options.

Unfortunately, our entire 'scm_t_port' structure is apparently part of
our public API and thus cannot be changed in 2.0.x.  Therefore, if we
hope to support either R7RS or SRFI-105 in 2.0.x, then I guess the only
option is to make a global weak key hash table, mapping ports to a table
of reader option overrides (and perhaps anything else we want to add to
the 'scm_t_port' structure).

Of course this global hash table must be protected by a mutex, which
will mean additional overhead for every 'read'.

I hope that we can make 'scm_t_port' private in Guile 2.2, and thus
restore our freedom to modify its structure.  Should we add deprecation
warnings in Guile 2.0 for applications that make direct use of this
structure?  Any ideas how to accomplish that?

What do you think?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]