From: Drew McDermott
Subject: Why no 'get-syntax'?
Date: 
Message-ID: <3D08F851.F7DBBEE6@yale.edu>
It sure would be nice if there were a function 'get-syntax' that
returned the entry for a character in a readtable.  Granted this object
would be useless except as the argument to a hypothetical 'set-syntax'
function, but that seems irrelevant to me.

Without 'get-syntax', I believe it is impossible to write a
macro-character that redefines another character within the scope of the
reading it does.  For instance, suppose you wanted to define your own
backquote, written as "!`" (i.e., excl-backquote), and use commas within
its scope to indicate the parts that aren't quoted.  The problem is that
there seems to be no way to restore the meaning of comma when the reader
exits.  One wants to write

   (unwind-protect
       (progn
          (establish new syntax for #\,)
          (read the next thing))
       (reestablish the old syntax for #\,))

You can do the reestablish using 'set-syntax-from-char' if you assume
that the old syntax for #\, = the built-in syntax for #\, .  But it
often won't, for example inside nested occurrences of "!`" .

One can work around this particular problem, but I'm amazed that the
language has a hole that makes it impossible to solve in general.

    -- Drew McDermott

P.S. There is probably a solution in which you copy the existing
readtable every time you enter the excl-backquote reader.  Blech.

From: Matthew X. Economou
Subject: Re: Why no 'get-syntax'?
Date: 
Message-ID: <w4owut2g9ap.fsf@eco-fs1.irtnog.org>
>>>>> "Drew" == Drew McDermott <··············@yale.edu> writes:

    Drew> P.S. There is probably a solution in which you copy the
    Drew> existing readtable every time you enter the excl-backquote
    Drew> reader.  Blech.

It's a hack, but you could create your own private readtable object,
copy the syntax of the character you want to back up to a character in
that private readtable with SET-SYNTAX-FROM-CHAR (note that it doesn't
copy a character's constituent traits), and restore it upon macro
exit.

Personally, I don't think it is unreasonable that readtables (and the
syntax elements they contain) aren't defined as externalizable
objects, or that they lack certain accessors, as this gives
implementers a little flexiblity.

-- 
Matthew X. Economou <········@irtnog.org> - Unsafe at any clock speed!
I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
From: Barry Margolin
Subject: Re: Why no 'get-syntax'?
Date: 
Message-ID: <AN9O8.34$4w2.1272@paloalto-snr2.gtei.net>
In article <·················@yale.edu>,
Drew McDermott  <··············@yale.edu> wrote:
>exits.  One wants to write
>
>   (unwind-protect
>       (progn
>          (establish new syntax for #\,)
>          (read the next thing))
>       (reestablish the old syntax for #\,))
>
>You can do the reestablish using 'set-syntax-from-char' if you assume
>that the old syntax for #\, = the built-in syntax for #\, .  But it
>often won't, for example inside nested occurrences of "!`" .
>
>One can work around this particular problem, but I'm amazed that the
>language has a hole that makes it impossible to solve in general.
>
>    -- Drew McDermott
>
>P.S. There is probably a solution in which you copy the existing
>readtable every time you enter the excl-backquote reader.  Blech.

Unfortunately, that's considered the canonical way to do it.  A
simplification is to make a copy at the beginning with the modified syntax,
and then bind *readtable* to the copy whenever you enter the special syntax
context.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.