I normally used to use (&rest forms) in the arglist when writing
macros. Lately I've seen lots of people using (&body body). What's
the gain? is there any difference?
dave
In article <···············@hawk.bu.edu>, David Bakhash <·····@bu.edu> wrote:
>I normally used to use (&rest forms) in the arglist when writing
>macros. Lately I've seen lots of people using (&body body). What's
>the gain? is there any difference?
Semantically they're identical -- the parameter is bound to the rest of the
subforms in the macro invocation. &body indicates that the forms are the
implicit progn-style body of a form. This information may be used by
pretty printers to format code differently, for instance.
A good example that would use both is:
(defmacro with-open-file ((stream-var filename &rest open-options) &body body)
...)
A use of this macro would be formatted as:
(with-open-file (f "filename"
:direction :output :if-exists :overwrite)
(print thing f))
If the &body were changed to &rest, it might be formatted as:
(with-open-file (f "filename"
:direction :output :if-exists :overwrite)
(print thing f))
Body forms are traditionally indented just a little bit more than the
containing form, while required, &optional, and &rest arguments tend to be
indented in line with the first argument.
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.