4 ms·
This isn't really generics in the C++ or Ada sense. This is code replacement using preprocessor macros and the stringize operator to create homogenous containe
by pkaler 13y ago
This isn't really generics in the C++ or Ada sense. This is code replacement using preprocessor macros and the stringize operator to create homogenous containers.
Generic programming usually implies that a package, class, or function is parameterized by types. And a generic/template instantiation phase has been added to the toolchain after the preprocess stage but before the type checking phase.
I would have called this homogenous containers.
>> Now you can use generics with arrays and sets just as you normally do in Java, C#, etc.
I would have documented that as:
"Now you can use homogeneous containers with arrays and sets just as you normally do in Java, C#, etc."
- jheriko 13y ago> I would have documented that as: "Now you can use homogeneous containers with arrays and sets just as you normally do in Java, C#, etc." ... and nearly nobody would have a clue what you meant.
- cowls 13y agoYes they are actually called generics in Java.. So this is just going to cause confusion, though I am very impressed with all the long words you used.
- smikhanov 13y agoIn Java, generics is a possibility to parametrize any type (not just a container) with another type. Just like in any other language that support generics. If you limit generics in Java to container types only (like at the original link), it would be absolutely more correct to call the result "homogenous containers". Take Callable<T>, for example. This is a generic type that is not a container and is not in the scope of project at the OP's link.
- pkolaczk 13y ago> This is code replacement using preprocessor macros and the stringize operator to create homogenous containers. Well, C++ templates are technically done by macro substitution, too, just they happen in a different stage of the compiler toolchain. > And a generic/template instantiation phase has been added to the toolchain after the preprocess stage but before the type checking phase. No, real generics are a part of the type-system; they should be part of the type-checking, not a magic preprocessing step. Therefore the compiler can do many cool things like imposing generic type constraints and also it can improve error messages a lot. So actually this solution is much, much closer to C++ templates, than to Java/Haskell/Scala/C# generics.