On 10.02.2018 14:05, Mark wrote:
On Saturday, 10 February 2018 at 12:35:39 UTC, Timon Gehr wrote:
So as expected, the difference is that for parametrically polymorphic functions, the type T /does not need to be known at compile time/.

According to this definition C++ doesn't support parametric polymorphism either, does it?

It does not. C++ templates are a kind of restricted hygienic macro system, similar to D templates. It is however common for programmers to apply PL-theoretical terms in a somewhat sloppy way, e.g. here: https://rosettacode.org/wiki/Parametric_polymorphism

(Fun fact: it is actually only called "polymorphism". "Parametric" is added to distinguish the term from its usage related to virtual method calls in object-oriented programming languages.)

To be fair, templates quite successfully simulate parametric polymorphism for a large subset of its use cases and the compile-time code generation aspect can be very useful too.

Are there any C-style languages that allow that?


C#. Also, to some extent, Java.

Reply via email to