3 ms·
> you find a simple line of C++ that says "y=f(x);", and it can do anything In practice you know what it does because of the context. Devs don't usually overri
by ogoffart 5y ago
> you find a simple line of C++ that says "y=f(x);", and it can do anything
In practice you know what it does because of the context. Devs don't usually override operator to mean the opposite of their meaning.
And in case there are doubts, editors have become pretty good at pointing out at the right location.
It is the same in C. is `y` or `f` or `x` a macro that could potentially have `return` or `goto` statements, that can potentially use a `__LINE__` meaning you can't use two occurrence on the same line or within another macro.
if `f` is a function, what are its side effects? Do conversion happen depending on the type of x? Or is it like a va_arg function that need the exact right type?
What i mean is that if you want to obfuscate things, you can do it in C just like in C++. But in normal code it's all pretty obvious.
- jstimpfle 5y agoIt's not that anybody wants to obfuscate things. But with clever mechanisms, people start to notice that they did only when it's too late. C macros can be useful, I would enjoy programming in this language much less if they weren't there. And if I build a reasonable abstraction with them, it's as little as a grep or go-to declaration to find out the definition. There are no implicit complicated resolution mechanims, no complicated internal data structures that keep what should be application data isolated in the compiler (so it has to be duplicated in other parts of the code). With macros, I just search for the name, and will usually quickly find the definition with very little additional indirection.