[Ecls-list] set-macro-character doesn't affect current reader??

Goffioul Michael goffioul at imec.be
Thu Nov 18 07:53:04 UTC 2004


Hi,

I tried to create a macro reader for '$' in ECL using the
following code:

(defvar +database+ (make-hash-table))
(setf (gethash 's1 +database+) "value1")
(setf (gethash 's2 +database+) "value2")
(defun dollar-macro-reader (stream char)
  (declare (ignore char))
  (let ((sym (read stream t nil t)))
    `(gethash ',sym +database+)))
(set-macro-character #\$ #'dollar-macro-reader t)
(print $s1)

Then I use it in ECL prompt as in the following session:

ECL (Embeddable Common-Lisp) 0.9d
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
        ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level.
> (load "testmacro")
;;; Loading #P"testmacro.lisp"

"value1"
#P"testmacro.lisp"
Top level.
> (print $s1)
The variable $S1 is unbound.
Broken at EVAL.

As you can see, during the loading, the new macro character is
used, but not from the prompt. Trying this under CLISP, it works
fine. Is this a bug or the intended behavior?

Michael.




More information about the ecl-devel mailing list