© Antonello Lobianco 2019
A. LobiancoJulia Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-5190-4_6

6. Metaprogramming and Macros

Antonello Lobianco1 
(1)
Nancy, France
 

Metaprogramming is the technique that programmers use in order to write code (computer instructions) that, instead of being directly evaluated and executed, produces different code that is in turn evaluated and run by the machine.

For example, the following C++ macro is, in a broad sense, metaprogramming:
#define LOOPS(a,b,c) \      CPP
  for (uint i=0; i<a; i++){ \
    for (uint j=0;j<b; j++){ \
      for (uint z=0;z<c; z++){ \

Here, the programmer, instead of writing the three for loops (supposedly in many places of her program), can just write LOOPS(1,2,3) and this will be expanded ...

Get Julia Quick Syntax Reference: A Pocket Guide for Data Science Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.