Lazy evaluation allows macros

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

A friend and I got into a discussion about building languages. One of the topics that came up was macros, and how useful they are.

If you don't know about macros, they are a serious feature for Lisp. It allows you to write "functions" that change the way the program runs. It does this by passing the macro the code that it intends to run--not the results of the code. The macro can then modify the code on the fly, running some bits and not running other bits, or changing how some bits will run altogether.

If Python had lazy evaluation, then it could have macros as well. How this would work is your function would get passed some values. But since it is evaluated lazily, it is really given placeholders that have all the instructions necessary to ...