From: Steven M. Haflich
Subject: Re: destructuring in DEFMACRO lambda-lists
Date: 
Message-ID: <3A9CFCC1.74D34376@pacbell.net>
Eric Marsden wrote:

> CMUCL is the only implementation I have access to which handles this
> as I expect. CLISP is being changed to support this. ACL accepts the
> macro definition but complains when it is used, as does GCL. Corman
> Lisp refuses the defmacro form.
> 
> Is this a valid lambda-list?

Yes, it is valid, and it seems most implementations do handle it
correctly.  Here is a test in ACL 6.0.  Is the following result
not what you "expect"?

<11> (defmacro with-pg-connection ((con &rest open-args)
                                   &body (forms decls))
       `(let ((,con (pg-connect ,@open-args)))
	  ,@decls
	  (unwind-protect
	      (progn ,@forms)
	    (when ,con (pg-disconnect ,con)))))
with-pg-connection
<12> (macroexpand
      '(foo (with-pg-connection "/etc/passwd" :direction :input)
	((declare (type stream s))
	 (declare (ignorable s))
	 (declare (day tuesday)))
	((print (read s))
	 (log "login")
	 (start-listener))))
(let ((with-pg-connection (open "/etc/passwd" :direction :input)))
  (declare (type stream s))
  (declare (ignorable s))
  (declare (day tuesday))
  (print (read s))
  (log "login")
  (start-listener))
t
<13>

From: Eric Marsden
Subject: Re: destructuring in DEFMACRO lambda-lists
Date: 
Message-ID: <wzir90id60t.fsf@mail.dotcom.fr>
>>>>> "smh" == Steven M Haflich <·······@pacbell.net> writes:

,----
| <12> (macroexpand
|       '(foo (with-pg-connection "/etc/passwd" :direction :input)
|         ((declare (type stream s))
|          (declare (ignorable s))
|          (declare (day tuesday)))
|         ((print (read s))
|          (log "login")
|          (start-listener))))
`----

this was not the type of use I was intending. I was expecting the
behaviour Paul Foley mentions:

   (with-pg-connection (conn "machine" :login "user" :password "secret")
      (declare (optimize debug))
      (pg-exec conn "DELETE FROM bar")
      (pg-exec conn "DROP TABLE more"))

which makes ACL complain (the old version I have, anyway). But I
gather this isn't standard code.

-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>
From: Barry Margolin
Subject: Re: destructuring in DEFMACRO lambda-lists
Date: 
Message-ID: <aNhn6.31$5t5.30732@burlma1-snr2>
In article <···············@mail.dotcom.fr>,
Eric Marsden  <········@mail.dotcom.fr> wrote:
>this was not the type of use I was intending. I was expecting the
>behaviour Paul Foley mentions:

That's a very curious expectation, since you went to the trouble of quoting
looking it up in the standard, and there's absolutely nothing in the
standard that suggests that CMUCL's behavior is intended.  I think the
CMUCL authors didn't see that the standard allows destructuring after &body
(as I said, it's a pretty strange thing to want to do, so it's not
intuitive), so they thought their feature was a compatible extension
(giving a definition to something that's undefined in the standard).  But
you went to the trouble of looking in the spec, found that it really does
say that normal destructuring is done, yet you still expected it to do a
complex parse.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.