[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
&mumbles at all levels.
- To: BUG-LISPM at MIT-MC
- Subject: &mumbles at all levels.
- From: Alan Bawden <ALAN at MIT-MC>
- Date: Tue ,20 Apr 82 22:27:00 EDT
- Cc: LISP-FORUM at MIT-MC, DULCEY at MIT-ML
Date: 04/19/82 22:30:38
From: DULCEY at MIT-ML
(defmacro foo ((one &optional (two ''two)) &body three)
`(list ,one ,two ',three))
>>ERROR: &OPTIONAL -- unrecognized & keyword in DEFMACRO.
While in the function ...
This probably isn't defined as working. However, it would be useful if
it did.
Indeed, this is currently defined to be an error. Would anyone object if I
actually made it act as it obviously should? I would like to fix this, and
simultaneously introduce a general tool for performing macro body parsing.
Proposed new special form: BIND-ARGUMENTS
example:
(bind-arguments ((a &optional (b *b*)) (foo) (barf))
b o d y)
(approximately)==>
(let ((gensym (foo)))
(if (not (and (<= (length gensym) 2)
(>= (length gensym) 1)))
(barf))
(let ((a (car gensym))
(b (if (< (length gensym) 2) *b* (cadr gensym))))
b o d y))
Now, you probably would never need a macro like this directly, but suppose you
had to write defmacro yourself:
(defmacro defmacro (name pattern &body body)
(let ((v (gensym)))
`(macro ,name (,v)
(bind-arguments (,pattern (cdr ,v) (ferror nil "Bad syntax: ~S" ,v))
,@body))))
That was easy wasn't it! So easy that ANYONE can do it. This seems to be the
right tool for bringing &mumble-argument-parsing to the masses.
Now I already have a working one of these (amazingly usefull in the right
situations I must add), and I would like to install it in the LispMachine as
the way defmacro etc work. This would have two noticeable effects:
1) &keywords would start to work at all levels in defmacro patterns. I presume
no one objects to this?
2) &list-of STOPS working... (finally I got around to the screw). Does ANYONE
use this feature? I could try and duplicate it, but if noone uses it (as I
suspect) I would rather just flush it. What to LispMachine people think?
(If no one raises objection, I'll ask info-lispm next.)
Unnoticeable effect:
3) The code produced by defmacro would be smaller and faster. (You would be
appalled at the code defmacro currently turns out.)