Is it correct to say:
Macros should only be used when we are branching over context - or establishing a context. When branching over values and conditions, only functions must be used.
Is it correct to say:
Macros should only be used when we are branching over context - or establishing a context. When branching over values and conditions, only functions must be used.
In simple words If you have some function lets say index in 20 different controllers. Which receive same set of params .You can use macro . Write one generic macro and use it in 20 controllers.(In my opinion).
In my book there are two valid use cases for macros:
If I understand the first part of your own definition correctly it maps cleanly onto the first of the afforementioned points. The second allows for something like this: https://github.com/expede/witchcraft#haskell-translation-table although I will admit that the example might be a little artificial.
Good usages of macros:
use
, alias
, import
or require
s with one line.My general statement of when to use macro-like things in languages is when you are needing to do something that is impossible to do efficiently in any other way.