Skip to content

Instantly share code, notes, and snippets.

@kisom
Created April 7, 2015 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kisom/d16772c7382d95c9b793 to your computer and use it in GitHub Desktop.
Save kisom/d16772c7382d95c9b793 to your computer and use it in GitHub Desktop.
Fun little function to count the number of times a macro gets expanded.
(defun count-macroexpansions (form)
(labels ((count-expansions (form n)
(multiple-value-bind
(expansion expanded)
(macroexpand-1 form)
(if expanded
(count-expansions expansion (+ n 1))
n))))
(count-expansions form 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment