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

&rest, &key in macro parameter list



Received: from THOMAS.kahuna.decnet.lockheed.com by ALAN.kahuna.decnet.lockheed.com via CHAOS with CHAOS-MAIL id 15603; 15 Jan 90 10:35:07 PST
Date: Mon, 15 Jan 90 10:34 PST
From: Robert D. Pfeiffer <RDP@ALAN.kahuna.decnet.lockheed.com>
Subject: &rest, &key in macro parameter list
To: SLUG@ALAN.kahuna.decnet.lockheed.com
In-Reply-To: <9001122259.AA13822@gnome.local>
Message-ID: <19900115183444.6.RDP@THOMAS.kahuna.decnet.lockheed.com>

    Date: Fri, 12 Jan 90 15:59:41 MST
    From: intvax!gnome!drstrip@unmvax.cs.unm.edu (David R. Strip)

    Consider the following trivial macro
    (defmacro foo (a b &key c &rest d)`( ,a ,b ,c ,d))

    (foo a1 b1 :c c1 d1)
    When you try top expand the example, you get an error that
    the instance doesn't match the pattern.

    Am I blind to somthing too obvious too see, or is there
    something subtle here>
    Strip
    drstrip@sandia.gov

Sorry, it looks like it's the "too obvious" case. :-)

According to the documentation section "Evaluating a Function Form",
&REST must precede &KEY so your macro isn't syntactically legal:

				.
				.
				.

       Keyword parameters are always optional, regardless of whether the
       lambda list contains &OPTIONAL. Any &OPTIONAL appearing after the
       first keyword argument has no effect. &KEY and &REST are indepen-
       dent. They can both appear and they both use the same arguments
       from the argument list. The only rule is that &REST must appear be-
       fore &KEY in the lambda list.