From: Vladimir V. Zolotych
Subject: writing macros
Date: 
Message-ID: <3BACA609.DD1FF6CA@eurocom.od.ua>
Hi

Consider the following (idiom ?):

(defmacro foo ((var &rest args) &body body)
  `(let ((,var (establish ,args)))
     (unwind-protect
	 (let ((,var ,var)) ,@body)
       (destroy ,var))))

What will I lose if write (progn ,@body) instead of 
(let ((,var ,var)) ,@body) ?

Thanks in advance

-- 
Vladimir Zolotych                         ······@eurocom.od.ua

From: Tim Moore
Subject: Re: writing macros
Date: 
Message-ID: <9oigo9$v82$0@216.39.145.192>
On Sat, 22 Sep 2001, Vladimir V. Zolotych wrote:

> Hi
> 
> Consider the following (idiom ?):
> 
> (defmacro foo ((var &rest args) &body body)
>   `(let ((,var (establish ,args)))
>      (unwind-protect
> 	 (let ((,var ,var)) ,@body)
>        (destroy ,var))))
> 
> What will I lose if write (progn ,@body) instead of 
> (let ((,var ,var)) ,@body) ?
> 

Are you worried about someone setting ,var in the body of the macro?  If
so, then yeah, you'll lose without the let.

Tim
From: Kent M Pitman
Subject: Re: writing macros
Date: 
Message-ID: <sfwitebjevr.fsf@world.std.com>
"Vladimir V. Zolotych" <······@eurocom.od.ua> writes:

> Consider the following (idiom ?):
> 
> (defmacro foo ((var &rest args) &body body)
>   `(let ((,var (establish ,args)))

This should almost certainly be ,@args

>      (unwind-protect
> 	 (let ((,var ,var)) ,@body)
>        (destroy ,var))))
> 
> What will I lose if write (progn ,@body) instead of 
> (let ((,var ,var)) ,@body) ?

Reliability.

Since VAR is supplied by the user, you have the risk that the 
user can do

 (foo (zing)
   (blah blah)
   (setq zing nil))

and that the value of zing when you go to destroy it will be NIL.

Probably even in that case you should do
  (if ,var (destroy ,var))
unless you have specially specialized DESTROY for NIL or whatever 
rescue value you want to choose.  You should definitely document 
the rescue value since there are still illegal values.
From: Vladimir V. Zolotych
Subject: Re: writing macros
Date: 
Message-ID: <3BACE743.2EE357DA@eurocom.od.ua>
��� ��������� ������������ � ������� MIME � ������� �� ���������� ������.
--------------1DDB005227589CF17F2EC51E
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

Exhaustive answer. Thanks.

Vladimir
--------------1DDB005227589CF17F2EC51E
Content-Type: text/x-vcard; charset=koi8-r;
 name="gsmith.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: �������� ��� Vladimir V. Zolotych
Content-Disposition: attachment;
 filename="gsmith.vcf"

begin:vcard 
n:Zolotych;Vladimir V.
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
·····················@eurocom.od.ua
fn:Vladimir V. Zolotych
end:vcard

--------------1DDB005227589CF17F2EC51E--