[gambit-list] Reading S-expressions

Marc Feeley feeley at iro.umontreal.ca
Sat May 2 23:23:05 EDT 2009


On 1-May-09, at 6:40 PM, Marc Feeley wrote:

> The API of that readtable functionality is imperative (it side-effects
> the readtable).  I would prefer a functional API (I admit, not too
> hard to do).  Anyway, the thing is that I view the "##" primitives as
> more fluid in their API as the non-## primitives.  There are no
> guarantees that the ## primitives will maintain their API over future
> versions of Gambit.  There are no guarantees for the non-## primitives
> either, but I would need a very good reason to change the API.  So the
> user can rely on the non-## primitives much more than the non-## ones.

Of course I meant "... more than the ## ones".

In the case of the readtable procedure ##readtable-char-class-set! I  
hesitate to make that particular API final.  Currently the API is:

(##readtable-char-class-set! rt c delimiter? handler)

The readtable rt will classify the character c as a delimiter (iff  
delimiter? is true) and when character c is encountered by the reader  
as an initial character of a token, it will call the handler  
procedure.  The handler's API is

(handler re c)

Here re is the "read-environment", a structure which packages various  
information useful for the reader (the input port, the readtable, the  
location information, etc), and c is the character that caused this  
handler to be called (multiple characters can have the same handler,  
for example open parenthesis and open bracket).

All of this is "reasonable", but might change in the future.  Moreover  
documenting this stuff is a slippery slope cause it exposes the  
reader's implementation, and the reader is a pretty complex beast.

Marc



More information about the Gambit-list mailing list