[racket] Remapping default character behavior in make-readtable

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Wed Jun 1 01:20:54 EDT 2011

Oh, wait, I can get the behavior I want as a procedure, I just can't
represent it as a single readtable on its own.  I got stuck thinking
that's what I had to do.  Never mind!  And thanks for kick-starting my
brain, Matthew.  :)

Carl Eastlund

On Tue, May 31, 2011 at 11:06 PM, Carl Eastlund <cce at ccs.neu.edu> wrote:
> I don't believe so.  I want to restore another readtable's behavior
> for unmapped characters, but leave all other mappings in the current
> readtable untouched.  I can't think of a way to get my hand on
> precisely that readtable.
>
> Specifically, I am trying to write a reader extension for dotted
> accessors, so that x.y.z reads as (dot x y z) or something similar.
> The way I envision implementing it is to first read a symbol using the
> default symbol reader, leaving "." as a terminating character, then
> checking for "." and chaining to a suffix if it is present.  For this
> to be a generic reader extension, that recursive read using the
> underlying symbol reader should leave all other extensions in place.
> I can only think of how to come up with the default readtable, or
> perhaps the readtable as it was just prior to this extension, but all
> subsequent extensions would be lost.
>
> Carl Eastlund
>
> On Tue, May 31, 2011 at 10:57 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>> The `read/recursive' and `read-syntax/recursive' functions accept a
>> readtable to use for the immediate read action, while nested reads use
>> the `current-readtable' parameter. That's intended as a general
>> chaining mechanism. Can you get the behavior you want by using those
>> functions?
>>
>> At Tue, 31 May 2011 14:29:29 -0400, Carl Eastlund wrote:
>>> The make-readtable function allows me to remap individual characters
>>> to new behaviors, and to remap the default behavior of unmapped
>>> characters to new behavior.  It also allows me to remap individual
>>> characters to the behavior of another readtable (such as the default
>>> readtable).  I cannot, however, remap the default behavior of unmapped
>>> characters to the behavior of another readtable.  (The same
>>> restriction appears to hold for "dispatch macro" mappings.)  Is there
>>> a way to do this that I have missed?  If not, could this ability be
>>> added?
>>>
>>> Carl Eastlund



Posted on the users mailing list.