From: David Bakhash
Subject: dispatch-macro-character...
Date: 
Message-ID: <cxjogwsfnjg.fsf@hawk.bu.edu>
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

From: Barry Margolin
Subject: Re: dispatch-macro-character...
Date: 
Message-ID: <zFR81.64$152.620589@cam-news-reader1.bbnplanet.com>
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.
From: David Bakhash
Subject: Re: dispatch-macro-character...
Date: 
Message-ID: <cxjhg2jffa3.fsf@hawk.bu.edu>
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