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

That's what macros are in Lisp and Scheme.


Does scheme give you access to the compiler's internal data structures? Can you for example write an extension that scans through the compiled code looking for, say, for loops and replacing them with something else?


Macro expansion happens just before compilation; you have the chance to alter the source code as it's being read by the reader just before compilation.

But I see what you're getting at; you mean global modifications to the compiler to interpret the whole language differently. A macro allows you to make syntax, but it doesn't change the meaning of other syntax elsewhere in the program; only allows the programmer to add syntax to the language.


Macros generate assembly?


Macros generate code, any code you want, including inline assembly if the scheme supports inline assembly, if not no.




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

Search: