|
|
|
|
|
by pcwalton
3845 days ago
|
|
> The resultant code will be identical once it has gone through the preprocessor. Well, sure. Hand-written assembly is also identical to compiled code, but we still have compilers :) > All you are gaining is prettier looking code, which shouldn't be discounted, but generics are about more than that. Yes. > Yet this example would be quite satisfactory to many regardless; curiously even you seemed excited about it. I don't think macros are a satisfactory replacement for generics, no. I don't know how I seemed "excited" about it. |
|
I mean when you convert the template<type> statement to the #define statement with the hypothetical preprocessor, it would be the same as if you had written the same code using #defines originally. They are functionally interchangable. If this satisfies generics in your mind (I don't think this describes you, for what it is worth), then standard C macros are more than sufficient to cover all the cases you would want, albeit less pleasant to type.
> I don't think macros are a satisfactory replacement for generics, no. I don't know how I seemed "excited" about it.
Consider your previous post misinterpreted then. It read to me like you thought the hypothetical code was theoretically different and solved problems with the previously provided macro, even though it was the exact same macro in both cases. The only difference was the slightly different syntax. Which, I might add, anyone can fairly easily add something similar to their Go code if they really wanted to.