Allows source location to work when a form is copied by a macro.
dspec
replacement-source-form original-form new-form => new-form-value
| original-form⇩ |
A Lisp form. |
| new-form⇩ |
A Lisp form. |
| new-form-value⇩ |
A Lisp object. |
A call to replacement-source-form can be used to allow the debugger and stepper to identify that original-form has been replaced by new-form in a macro expansion. Forms in a macro expansion that are eq to forms in the arguments to the macro will be identified automatically, but some macros (such as iterate
) need to generate new forms that are equivalent to the original forms and wrapping them with replacement-source-form allows them to be identified too.
original-form should be a form that occurred in the arguments to the macro and does not otherwise occur in the expansion of the macro. new-form should be a form that was created by the macro.
The value of new-form, new-form-value, is returned when the replacement-source-form form is evaluated.
Without the replacement-source-form, the calls to pprint would be unknown to the debugger and stepper because the forms do not occur in the original source code:
(defmacro pprint-for-print (&body forms)
`(progn
,@(loop for form in forms
collect
(if (and (consp form)
(eq (car form) 'print))
`(dspec:replacement-source-form
,form
(pprint ,@(cdr form)))
form))))
LispWorks® User Guide and Reference Manual - 18 Feb 2025 15:32:18