Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Macros are not functions, macros are a mechanism for adding features to the language itself.


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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: