3 ms·
Consider that macros generally don't expand syntax - because there is very little syntax anyway, and what you have is a tree of data and function calls. A Macr
by p_l 5y ago
Consider that macros generally don't expand syntax - because there is very little syntax anyway, and what you have is a tree of data and function calls.
A Macro just lets you write a function that will be executed by compiler to manipulate such tree, meaning that you can have equivalent of adding syntax like "with/using" from some languages by writing a function that takes as arguments the object and a block of code, then re-emits the same block of code but adding object.Dispose() call at the end. Or whatever else you need.
But they are still normal functions - it's the time of execution that changes.
- mwattsun 5y agoI generally never used macros when I wrote C because the C macro language is lacking, there are a lot of pitfalls and saving function call overhead is usually not that important. I think I'll try to get a new understanding of Lisp macros by trying to come up with a language feature in C# or Dart that I really want but can't implement without a lot of non-intuitive difficulty, but could easily in a Lisp style macro that the compiler could use to build in a new feature at compile time.