Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Although macros can make life difficult for clever editors that want to introspect code.


Don't macros actually help both compiler writers and end users here? Macros are expanded at macro-expansion time, which is a stage before code gets evaluated. Macro-expansion is akin to source code pre-processing in other languages. Therefore all necessary context for fully expanding a macro in Lisp is maximally a source file and minimally a single macro form within some shared compilation environment. Clever editors (like Emacs extensions commonly used by Scheme, Common Lisp, and Clojure programmers) make ample use of this functionality to provide all sorts of code introspection and other smart editing functionality.


Syntax level macros (like C) are unhygienic and basically dangerous, while proper (ast-transforming rather than syntax transforming) hygienic macros are ok for both tools and humans. Macros got a bad reputation just because there were poorly implemented for C.


SLIME is your friend. Stepwise forward and backward macro expansion and contraction. It's a thing of beauty.


This is mitigated by the fact that Clojure doesn't expose reader macros to the user.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: