Generally metaprogramming is uned to do what it is called, use the program 
itself as data that can be transformed. There is a lot you can do with it, some 
of the use cases I can name, but others are only limited by your imagination 
and the limits of the metaprogramming facilities of the language.

  * You can create a macro that adds debug information to a program in the way 
you need it at that moment.
  * You can write macros that to add create new language features/ 
expressability. 
[https://github.com/andreaferretti/patty](https://github.com/andreaferretti/patty)
  * If you are in an environment, where you need to write a lot of glue code, 
you could use macros to generate the glue code. 
[https://github.com/krux02/opengl-sandbox](https://github.com/krux02/opengl-sandbox)
  * Almost any code snippet you use often can instead be macro (not really 
metaprogramming, since it doesn't have any behavior depending on the argument)
  * Anything that requires you to have a code generator in other languages, you 
can instead solve with metaprogramming. So if projects like YACC would be 
translated to nim its code generation part could be replaced by macros.
  * You could write code analysis tools, without the aid of an external 
language parser.
  * embedded domain specific languages



Basically it extends the amount of problems you can solve within the language. 
But be careful, with power comes responsibility, and I am pretty sure in an 
environment wher macros are just available to any developer, you have a lot of 
opportunities to write unmaintainable code. 

Reply via email to