2

Given class MyClass<T> what is the proper terminology to describe what MyClass does with the generic type parameter?

Implements? Uses? These don't sound right. I've skimmed through MS documentation on generics and they seem to talk around it without using a term.

My question came to mind when writing a comment about code that inspected the type of generic type parameter to see if it was assignable from a particular base type. I was planning to say something like: "check to see if the generic class verbs the specified type". I can word it differently, but wanted to know if there was a good verb to use.

5
  • Your question is unclear. How would you use such a verb?
    – SLaks
    Jul 3, 2013 at 14:10
  • 1
    What does a function do with a parameter? Accepts it perhaps? "The generic type/function accepts the generic type parameter".
    – Jodrell
    Jul 3, 2013 at 14:14
  • With @SLaks here: "can you use it in a sentence"?
    – CodeCaster
    Jul 3, 2013 at 14:15
  • @Slaks -- see my edit. "check to see if the generic class verbs the specified type"
    – jltrem
    Jul 3, 2013 at 14:16
  • 2
    Just "It uses the type parameter" would do. Jul 3, 2013 at 14:17

7 Answers 7

6

The T parameter is part of the type, so you should just say MyClass of T. It "does" nothing with T.

1
  • You can think of T as a parameter of MyClass so MyClass most certainly can "do" something with T. For instance, you can cast a member to type T. Jul 3, 2013 at 14:39
4

From simple view, you could say that generic function accepts a generic type parameter.

You could specialize this to contains, but if you want to be fancy, you might say, a generic type reifies a type parameter.

From the Wikipedia article:

"In C#, reification is used to make parametric polymorphism implemented as generics as a first-class feature of the language"


The definition on Dictionary.com

re·i·fy/ˈriəˌfaɪ, ˈreɪ-/

verb (used with object), re·i·fied, re·i·fy·ing.
to convert into or regard as a concrete thing: to reify a concept.

1
  • I will probably stick with /uses/ for my comment, but /reifies/ is what I'm looking for. Thanks.
    – jltrem
    Jul 3, 2013 at 14:28
2

The way it's used in the MSDN documentation is MyClass of T.

1

It does not do anything with T. T is its parameter.

void doNothing(int i)
{
}

What does this do with i? Nothing. i is its parameter.

1

The system binds an open-generic type MyClass<> to a particular type (e.g. Int32) to yield a closed generic type MyClass<Int32>. The former class is effectively used only as a template for the system to produce the latter; the latter has the type built into it. Note that the generation of the closed-form generic from the open-form generic is done by the system, and not by the class itself. A class can include constraints on its generic parameters, but otherwise has no control or involvement in the process.

2
  • so rather than "the generic class /uses/ the type" you suggest a more correct statement to be "the generic class /is bound to/ the type"?
    – jltrem
    Jul 3, 2013 at 15:23
  • @Jos.Schlitz: That might be the best terminology, though MyClass<Int32> doesn't actually exist until the binding is complete; it's the product of binding MyClass<> with type parameter Int32.
    – supercat
    Jul 3, 2013 at 15:28
0

Type parameterization is what I would call it. Also type specification deferment.

1
  • So MyClass parameterizes the type and defers its specification.
    – Mike Cheel
    Jul 3, 2013 at 14:12
0

Since List<int> is a "List of int", probably the 'verb' you're looking for is "the generic class is of the specified type"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.