This weekend I have been pondering the inverse of macro expansion. Meaning - static analysis of code to detect patterns in which atoms appear to be repeated in a way which could be better abstracted by utilizing a macro. The only hit I can get on google after various searches is a reference on the interlingua/KIF mailing list
http://www-ksl.stanford.edu/email-archives/interlingua.messages/364.html in which the author states:
" Macro expansion is adequate to map from a high level notation to a low-level notation. That is a simple, linear-time process. But the inverse of macro expansion is in general undecidable. "
This is believable, however it still seems that a tool could exist which would make suggestions to the author of where a macro could be advantageous (or even match against existing macros). In the world of shen how difficult would such a tool be to write I wonder?