Question

In computer science, what is the abstract common name of types and values (I mean an abstract "something" that can be a type or a value) ?

To be more specific:
If we have template <typename X> or template <int X> what is the abstract name of X?

Was it helpful?

Solution

Microsoft uses "type parameter" for C++ and C#. But that's Microsoft and not necessarily representative.

C# calls it a generic type parameter. See this MSDN article for details.

In a generic type or method definition, a type parameters is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type.

[emphasis added]

C++ calls it a type parameter. See this MSDN article for more details.

Templates, which are sometimes called parameterized types, are mechanisms for generating functions and classes based on type parameters.

[emphasis added]


Just to prove others use different terms, this article uses "type parameter" as well as "template parameter."

Recall that the standard containers actually have at least two parameters: the element type and an allocator type.

and then later on:

Notice that we've left out the name of template parameter in the declaration of List, above.


It's worth pointing out though that generics are not templates as explained in the linked article.

I think the key difference is:

Generics are generic until the types are substituted for them at runtime. Templates are specialized at compile time so they are not still parameterized types at runtime

Licensed under: CC-BY-SA with attribution
scroll top