Created
April 7, 2015 22:28
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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