Subject: Re: [constants] from a reader macro
From: Erik Naggum <erik@naggum.no>
Date: 2000/02/24
Newsgroups: comp.lang.lisp
Message-ID: <3160383123856271@naggum.no>

* Erik Naggum
| it seems by your use of the backquote that your core confusion is to
| believe that "macro" in "reader macro" is the same kind of "macro" as in
| "macro function".  it isn't.

* Tunc Simsek
| I must confess that I don't understand this remark, they behave in the
| same way, their ranges are lisp code.

  no.  that's the issue.  the "range" of macros is Lisp code which will be
  processed by the caller, usually the compiler on code it processes.  the
  "range" of reader macros is Lisp objects the Lisp reader was asked to
  pick up from some textual input source, such as by the compiler when it
  compiles files.  viz, a macro to build a matrix would return the code to
  be evaluated or compiled instead of the macro form, while a reader macro
  to build a matrix would return the matrix as a constant object.

  moreover, they do not behave in the same way.  a macro function is called
  with Lisp code it can transform at will, while a reader macro is expected
  to build Lisp objects from parsing input.  the "domain" of the former is
  Lisp objects and code, while the "domain" of the latter is characters and
  streams.  this must be understood in depth before you can make use of
  reader macros productively.  most Lisp programmers don't know how the
  Lisp reader and printer work to begin with, or how to add new objects to
  the read-write-consistency paradigm.  indeed, not understanding how Lisp
  has solved this very difficult problem is why most designers of protocols
  and syntaxes get them so incredibly wrong.

| My intent is to get a simple way of expressing constant matrices which I
| use a lot and don't like to type in (make-matrix ... all the time.

  this is good.  however, you should regard your reader macro as a
  short-cut for #.(make-matrix ...), not for (make-matrix ...) if you want
  to build the matrix in the reader macro (and nothing else makes sense).

| I actually know of one problem with using #\[ as a macro character:
| allegro uses it as a super paranthesi.

  which "allegro" is that?  Allegro CL does not violate the standard by
  interpreting [ and ] as anything but ordinary symbol name constituents.

#:Erik