common-lisp Which form to use?


When writing macros that expand into forms that might involve grouping, it is worthwhile spending some time considering what grouping construction to expand into.

For definition style forms, for instance, a define-widget macro that will usually appear as a top-level form, and that several defuns, defstructs, etc., it usually makes sense to use a progn, so that child forms are processed as top-level forms. For iteration forms, an implicit tagbody is more common.

For instance, the body of dotimes, dolist, and do each expand into an implicit tagbody.

For forms that define a named "chunk" of code, an implicit block is often useful. For instance, while the body of a defun is inside an implicit progn, that implicit progn is within a block sharing the name of the function. That means that return-from can be used to exit from the function. Such a comp