From 74563d904148719220b1f14c9afbd1ebf5232dac Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Sun, 28 Oct 2018 15:41:33 +0000 Subject: [PATCH] Macro hygene: use a generated (anonymous) symbol in macro expansion The variable name 'next-hooks' potentially (theoretically) clashes with variable names defined in the body of the expansion. Don't clash by using an anonymous symbol. --- helpers.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/helpers.lisp b/helpers.lisp index bd43aa7..58364f4 100644 --- a/helpers.lisp +++ b/helpers.lisp @@ -83,12 +83,13 @@ a `call-next-hook` to its caller as it is the content of the rendered page. " - `(progn - (defun ,name (,@args next-hooks) - (flet ((call-next-hook (content context) - (funcall (pop next-hooks) content context next-hooks))) - ,@body)) - (push (function ,name) *render-hooks*))) + (let ((next-hooks-sym (gensym))) + `(progn + (defun ,name (,@args ,next-hooks-sym) + (flet ((call-next-hook (content context) + (funcall (pop ,next-hooks-sym) content context ,next-hooks-sym))) + ,@body)) + (push (function ,name) *render-hooks*)))) (defun render-page-with-hooks (content context) (let ((hooks (reverse (cons #'(lambda (p c next-processors) -- GitLab