O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to metaprogramming

In an ideal and simplified form, programming consists of two clearly separated things: program code and data. Once you are finished with your code, it is like carved in stone, non-malleable.

Metaprogramming means writing programs that write programs. It varies wildly how different programming languages do this. For instance, C has a preprocessor that reads specific tags starting with # and expands them before handing the result to the actual compiler. In C, those expansions are quite free-form; they are just simple text transformations without much safety. Specifically, macros written in C (and a few other languages) are not hygienic: they can refer to variables defined anywhere, as long as those variables ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required