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

Macros and destructuring and functions, oh my!



cc: BUG-lisp at MIT-MC, BUG-lispm at MIT-MC, macsyma-i at MIT-MC

    Sorry, Dan, I beg to differ with you on the philosophical nature of macros.
    Macros certainly are functions, of one argument.

No, I still don't agree.  A macro is implemented as a function of one
argument in the meta-language.  From the point of view of the
meta-language it is a function of one argument.  But functions in the
meta-language have nothing to do with functions in the language; from
the point of view of the language, a macro is a translator and not a
function.

							   Now, the fact
    that macros and functions are invoked by means of the "same syntax"
    is sort of a coincidence, and not at all essential.  

Yes.  That's what I said, too.  I don't see why you are debating this.
I went on to say that this coincidence should not fool you into
thinking that lambda lists and defmacro patterns are "the same thing".

    Now, it is true that in practice up until now destructuring has been the most
    useful for macros, which commonly parse apart their arguments into known
    fixed pieces.  There is also the fact that ordinary functions in effect
    already get one level of destructuring by the fact that they are
    considered to get many named arguments rather than a single one (which
    is usually a "vector" of some sort); but after all, what are &OPTIONAL
    and &REST but destructuring mechanisms?  There is something to be said
    for unifying that mechanism with the one used by DEFMACRO and the NIL LET,
    provided it can be done without undue clutter.

No, I do not buy this argument at all.  &OPTIONAL and &REST are not
"destructuring an argument vector".  Functions are not passed an
argument vector; they are passed several arguments.  &OPTIONAL has
absolutely nothing to do with destructuring; you might think &REST
does, but I don't; the only reason that list is there is because it is
the easiest way to let you deal with an unanticipatable number of
arguments.  That list got CONSed; it did n't "fail to get
destructured".