|
|
|
|
|
by staticint
3846 days ago
|
|
I think you may be reading too much into the hypothetical implementation. It was highlighted as nothing more than syntax sugar, after all. If all you do is translate: template<type> max(...) into #define defmax(type) ...
and max<int>(...) into defmax(int); max(...)
The resultant code will be identical once it has gone through the preprocessor. All you are gaining is prettier looking code, which shouldn't be discounted, but generics are about more than that. Yet this example would be quite satisfactory to many regardless; curiously even you seemed excited about it. |
|
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.