4 ms·
It is incorrect to say that the c approach is no generics. C has its precompiler macros which functionally provide a crude form of generics.
by Pxtl 12y ago
It is incorrect to say that the c approach is no generics. C has its precompiler macros which functionally provide a crude form of generics.
- wheaties 12y agoC macros are the worst form of macros. They are string substitution without type checking and can very easily leaf to all sorts of issues. That said I'm in the macros camp instead of generics just because I think go authors would actually do it.
- asb 12y agoHygienic macros for Go (i.e. an equivalent of sweet.js http://sweetjs.org/ http://sweetjs.org/) would be very interesting.
- copsarebastards 12y agoIf you're rooting for language features based on the willingness of your language designers to implement them rather than what will make the language better, your language ecosystem is fundamentally broken and it's time to move on.
- dragonwriter 12y agoPreprocessor-based solutions (and cleaner, IIRC, than C preprocessor macros) for Go generics exist, too. So, "no generics" for C is as accurate as "no generics" for the Go status quo.
- Pxtl 12y ago"exist" is not the same as "is built into the language and compiler".
- dragonwriter 12y agoNeither C nor Go has generics, preprocessor based or otherwise, built into the language and compiler. Both C and Go can have (and, in fact, it has been done in both) some degree of generics implemented in a preprocessor-based way using only features built into the language and compiler. So, again, I would maintain that "no generics" is no more valid of the Go status quo than it is of the C status quo.
- masklinn 12y agoC's macros are a form of code generation. In context, generics is parametric polymorphism[0] which does not imply code generation, though it can be extended to support it (template specialisation). Parametric polymorphism is about static type-safety. [0] http://en.wikipedia.org/wiki/Parametric_polymorphism http://en.wikipedia.org/wiki/Parametric_polymorphism