Next: , Previous: merge-declaration-envs, Up: API


parse-body

Syntax

— Function: parse-body body-and-decls &key documentation whole ⇒ body, declarations, docstring

Arguments and Values

body-and-decls
A list which can contains declarations, a documentation string, and forms.
documentation
A boolean.
whole
An object.
body
A list of forms.
declarations
A list of declarations.
docstring
A documentation string.

Description

The function parse-body splits an &BODY argument of an extended lambda list into its three distinctive parts which are returned as multiple values:

  1. The actual body forms supposed to be evaluated.
  2. The declarations if any.
  3. The documentation string if any.

A documentation string is only parsed if documentation is true. whole is used to indicate the context if an error is signalled, and should hence be a symbol naming the operator parse-body is used to define.

Examples

  PARSE-DECLARATIONS> (parse-body '("Also sprach Zarathustra.."
                                    (declare (optimize speed))
                                    (declare (author "God"))
                                    (setf *universe* (big-bang))
                                    (frob-light))
                                  :documentation t)
  => ((SETF *UNIVERSE* (BIG-BANG)) (FROB-LIGHT))
  => ((DECLARE (OPTIMIZE SPEED)) (DECLARE (AUTHOR "God")))
  => "Also sprach Zarathustra.."

Exceptional Situations

Signals an error of type SIMPLE-ERROR if body-and-decls contains more than one documentation string, and documentation is true.

See Also

parse-declarations

Notes

The symbol PARSE-BODY is not exported from the library Parse-Declarations to avoid a name conflict with the Alexandria library. However, this symbol is guaranteed to be part of Parse-Declarations, and can hence be referenced directly, or imported explicitly, if users don't want to use Alexandria.