[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



    Date: 9 March 1981 23:51-EST
    From: Gerald Jay Sussman <GJS at MIT-AI>

    The macros IF-FOR-LISPM and IF-FOR-MACLISP and IF-FOR-MACLISP-ELSE-LISPM
    ought to be defined by default in Maclisp just as on the Lisp machine.
    I don't want to use the #M and #Q because they are not Lisp-like.

The # macro is as Lisp-like as ' ` or ,.  Often, it describes some read-time
action to the following form, e.g. wrapping a (FUNCTION ...) around it,
reading it with certain global state modified, or making the form disappear
entirely.

Use of IF-FOR-LISPM and IF-FOR-MACLISP is discouraged:
1) They assume that the only conditionalizations you would want to make are
   for the Lisp Machine and MacLisp.  They are not extensible in any way.
2) They can only appear in a place where the compiler will do macro
   expansion.

The encouraged replacement is #+Lispm and #+MacLisp, which are newer forms
of #Q and #M.  #+<condition> <form> is read as <form> if (status feature
<condition>) is true.  Otherwise, <form> disappears entirely.  Thus, one can
do #+NIL, #+Franz, #+SchemeChip, etc. for conditionalizing code which must
run many different places, without having to create new constructs and
add them to every Lisp implementation around.

*** Note Well ***  I am not encouraging free and indiscriminant use of this
construct.  I don't consider it in any way elegant or an integral part of
Lisp.  It is simply an unfortunate engineering necessity needed to make
programs run in many different places.

In general, one uses #+ at the very beginning of one's code to set up
program-specific macros which are then used further on.  E.g.:

(defmacro symbol-definition (symbol)
	  #+MacLisp	`(cadr (getl ,symbol '(expr subr lsubr)))
	  #+Lispm	`(fsymeval ,symbol)
	  #+Franz	`(getd ,symbol))

Then the rest of your code would be written in terms of the
"symbol-definition" macro, and you must endure the # ugliness only once.
MC:ALAN;NSTRUCT is a good example of a large program conditionalized in
this fashion.  It implements the Lisp Machine defstruct macro, runs in
three separate Lisp implementations, and is used heavily in all three.