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

Reader hacks

    From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>

        From: Guy Steele <gls@THINK-AQUINAS.ARPA>

        I am writing code for reader macros and find I need the following
        (1) A predicate that is true of whitespace characters and false
    	of all others. . . . 

    Is this something different from
      (or (char-equal char #\space)
          (not (graphic-char-p char))) ?

Well, i was going to say that backspace didn't fit this mold, but CLtM
says it isn't a token constituent unless quoted.  Oh well.  Anyway,
have we ever speculated on the relationship of predicates like
graphic-char-p or this hypothetical whitespace-p, and readtables?  How
well-defined is it to transfer the syntax of one character to another?

        (2) I find I can't easily write myself something akin to
    	READ-DELIMITED-LIST that handles dotted lists because of
    	the problem of recognizing all-dots tokens.  PEEK-CHAR can
    	only peek one ahead, so I can't tell whether there is a
    	space after a dot before calling READ recursively.

    How about a way (a special variable?) to turn off the somewhat silly
    restriction that you can't have a symbol named .?

Flushing the restriction of unquoted all-dots tokens would only
ameliorate the problem a bit, because he would still have to read the
token himself because he wouldn't be able to unread-char both the dot
and the following token.  Besides all the other stuff which is almost
what read-delimited-list provides.  Restated, the problem is that one
might want read-delimited-list to barf about cons dots;  for instance,
to implement #( syntax.  Alternatively, one might want to do
variations of ordinary parentheses in which cons-dot is meaningful.
So having some sort of flag argument to read-delimited-list makes

    Alternatively, how about a function that does the token-isolating
    portion of READ but not the printed-representation-to-object
    conversion portion of READ?

Do you think this could be done without over half the implementors
having apoplectic fits, and with no loss of life?