Hacker News new | ask | show | jobs
by probably 5428 days ago
Please excuse my ignorance here --

> instead are able to write code that modifies code and generates code as easily as if you were writing the original code in the first place

Is this often done? I know it is conceptually possible with the advantage being that the same functions used to manipulate lists and data are available for this task, but I got the impression that not many people actually do this? For instance...

http://stackoverflow.com/questions/6480053/modifying-functio...

2 comments

AFAIK this is actually incredibly common. The example that springs to my mind is people writing matrix libraries that manipulate the code to "compile" it to use more efficient algorithms. People do this kind of thing in C++, such as in Blitz++, but you end up having to pull heroics with the type system (and end up with some pretty abused syntax at times) to accomplish what is much easier in a homoiconic language like Lisp.
I've been using Common Lisp for quite a few years now yet I have written very few macros (although I have used a great many written by others!), however there's times when you need their power when nothing else will do.

Also because you can modify the syntax with them they can really clean and clear up your code.