hey,
I am using print from Emacs Lisp to print object which include
vectors. If you've ever played with vectors in Emacs, then you might
recall that they are delimited by brackets:
(vector 2 3 4) == [2 3 4]
and the Emacs Lisp reader understands these delimiters. However, they
are not standard in CL. CL vectors are delimited as follows:
#(2 3 4)
With Paul Graham's `defdelim' macro, I was able to get the CL reader
to accept this:
#[2 3 4]
but unfortunately, Emacs doesn't use sharps (`#'), and so I have tried
(unsuccessfully) to get the CL reader to understand
[2 3 4]
Here's the code I'm using:
(defmacro defdelimiter (left right param-list &body body)
"Define a new LISP delimiter!"
`(ddfn ,left ,right #'(lambda ,param-list ,@body)))
(let ((rpar (get-macro-character #\))))
(defun ddfn (left right fn)
(set-macro-character right rpar)
(set-dispatch-macro-character #\# left
#'(lambda (stream char1 char2)
(declare (ignore char1 char2))
(apply fn
(read-delimited-list right stream t))))))
and then I use it like this:
(defdelim #\[ #\] (&rest args) `(vector ,@args))
How can I fix it so it can deal without having the sharps?
dave
In article <···············@hawk.bu.edu>, David Bakhash <·····@bu.edu> wrote:
>How can I fix it so it can deal without having the sharps?
Use set-macro-character instead of set-dispatch-macro-character. This
seems too obvious -- am I missing something?
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Barry Margolin <······@bbnplanet.com> writes:
> In article <···············@hawk.bu.edu>, David Bakhash <·····@bu.edu> wrote:
> >How can I fix it so it can deal without having the sharps?
>
> Use set-macro-character instead of set-dispatch-macro-character. This
> seems too obvious -- am I missing something?
I doubt you're missing anything; you're simply dealing with a newbie.
That's all.
Can you explain the difference between those two?
What does `dispatch' really mean to the reader?
dave