[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: destructuring and &mumbles
- To: DLW at MIT-AI, Guy.Steele at CMU-10A
- Subject: Re: destructuring and &mumbles
- From: Alan Bawden <ALAN at MIT-MC>
- Date: Tue ,30 Sep 80 03:36:00 EDT
- Cc: LISP-FORUM at MIT-MC
I don't see where &mumbles have anything to do with destructuring.
As the person who first combined destructuring and &mumbles in
defmacro, let me tell you what I thought I was doing:
Sometimes you wanted defmacro to do destructuring, we had that and it
was useful, but sometimes you wanted it to behave like defun and have
optional arguments. Realizing that you could allow both syntaxes I
wrote the defmacro that the LispMachine is still using, but the
interaction between the two features is not smooth. For example,
&mumbles are not allowed in places other than the top-level argument
list, why not
(defmacro yech (foo (bar &optional baz) &optional (qaz 'wsx)) ...)
?? Also why doesn't
(defmacro fruity (&optional ((a 'apple) (b 'banana))) `(cons ,a ,b))
define a macro such that (fruity) expands into (cons 'apple 'banana)
and (fruity (x y)) expands into (cons x y) ?? The reason "why" is
because this is really a KLUDGE to allow defmacro to look like defun
sometimes and destructure other times.
The fact that (a &rest b) happens to mean the same thing as (a . b) is
amusing, but misleading. I would never write (a (b c) d &rest e) since
(a (b c) d . e) is more clearly destructuring. Nor would I write
(a &optional b . c) instead of (a &optional b &rest c) since the latter
is more clearly defunish.
I don't think that &mumbles and destructuring combine to make any kind
of reasonable pattern matcher. If the interaction had turned out to
be amazingly elegant, then perhaps we would have moved the combined
mess back into defun, but it ISN'T. In defmacro you frequently want
BOTH features, but in defun you rarely need destructuring so there is
no reason to clutter it up.