Re:Stop Writing JavaScript Compilers, Make Macros Instead
by ahunt09 on Wednesday January 08, 2014 @03:06PM
(#7026164)
So, after puzzling around with the macro for swap a bit, it seems like macros are like functions, except without the scoping rules, which suggests to me that we now have two kinds of functions, to keep track of in the code, each of which look identical, but behave differently. swap(a,b) looks like a function, but can interact with all the variables in the same scope (or above) as when it's called (is this the same for global functions?). Maybe I'm missing something big, but that seems dangerous when the macro is declared in another file, and I have to go figure out how it behaves.
[ Parent
| on HN ]
Re:Stop Writing JavaScript Compilers, Make Macros Instead
by MBlume on Wednesday January 08, 2014 @03:31PM
(#7026364)
Macros are not functions, macros are a mechanism for adding features to the language itself.
Re:Stop Writing JavaScript Compilers, Make Macros Instead
by ahunt09 on Wednesday January 08, 2014 @03:37PM
(#7026410)
Maybe I wasn't clear. I am not saying that macros are functions. I'm saying that without seeing the implementation, both look identical, and thus could be conflated, but do not treat scope identically.