[comp.lang.lisp] *readtable* and read macros

bharat@uicslsv.cs.uiuc.edu (10/17/88)

I'm using a read macro with set-macro-character as in

(set-macro-character #\? #'create-variable)

After reading the data file I want to restore the original readtable,
and the following should work (if I'm understanding Steele correctly).

(setq *readtable* (copy-readtable nil)) -------1

But this doesn't and I make do with the foll. code.

(defvar *temp-readtable* (copy-readtable))
(load "read-macros.lisp") etc....
(setq *readtable* (copy-readtable *temp-readtable*)) ------2

This is quite kludgy.

Is this the only way to do it, or should (1) work (i.e. is the LISP on
the TI explorer buggy)?

-Bharat

************************************************************************
R.Bharat Rao
bharat%uicsl@uxc.cso.uiuc.edu , bharat@uicsl.csl.uiuc.edu
************************************************************************

lou@bearcat.rutgers.edu (Lou Steinberg) (10/19/88)

In article <4400005@uicslsv> bharat@uicslsv.cs.uiuc.edu writes:

> After reading the data file I want to restore the original readtable,
> and the following should work (if I'm understanding Steele correctly).
> 
> (setq *readtable* (copy-readtable nil)) -------1
> 
> But this doesn't [work]

To quote Steele (p. 361)

    (setq *readtable* (copy-readtable nil))
    will restore the input syntax to standard Common Lisp syntax

But do make sure it *really* isn't working before claiming a bug - I
would assume this sort of thing gets tested by major Lisp suppliers.

If it really doesn't work, I'd do

(let ((*read-table* (copy-readtable)))  ; rebind to copy of current one
     (load "read-macro-file.lisp")
     (load "data-file")
)

On exit from the let, the original binding is restored.
-- 
					Lou Steinberg

uucp:   {pretty much any major site}!rutgers!aramis.rutgers.edu!lou 
arpa:   lou@aramis.rutgers.edu