4 ms·
>Finally, in your Scala example, keep in mind that unlike ML functors, it has the usual constructor problem that many simple genericity mechanisms have: constru
by milesrout 10y ago
>Finally, in your Scala example, keep in mind that unlike ML functors, it has the usual constructor problem that many simple genericity mechanisms have: constructing instances of the parameter type. In Scala, that means you end up working with CanBuildFrom or implicit arguments; C# and Eiffel have specialized (and ultimately, still less flexible) language constructs to deal with that.
What does C++ have? Or what do those languages not have? Do they not work the same way as C++, where you can just write:
auto t = T{args...};
?
- rbehrends 10y agoTemplates in C++ are basically macros and can do a lot more as a result (and that comes with the usual costs, such as your code size potentially blowing up, getting in the way of separate compilation, and the problems with enforcing constraints on parameters; concepts have yet to make it into the language). It's totally different from languages where parametric polymorphism is part of the type system proper.
- milesrout 10y agoTemplates in C++ are not 'basically macros' in the C++ sense.