lesderid
lesderid

Reputation: 3430

What's the (official) term for a type's type?

I'm writing an application using Roslyn to syntactically and semantically analyse C# source code. For each type defined in the source code being analysed, I would like to store whether it's a reference type (a class), a value type (a struct) or an interface.

What's the appropriate/official term for a type's type?

Example:

class A
{
    //This type's type (A's type) is 'class' (i.e. a reference type).
}

Upvotes: 7

Views: 271

Answers (3)

Kirill Osenkov
Kirill Osenkov

Reputation: 8976

I've seen us use "kind" in the Roslyn source code, as in "there are 5 possible kinds of types that can be declared". However I don't think there is an officially defined term for this. I'd use "kind of type" or "kind".

Upvotes: 2

Andreas Rossberg
Andreas Rossberg

Reputation: 36098

In type theory, the type of a type is usually called its kind. That primarily describes the form of parameterisation of a type, although it can be used for other classifications, too. But I'm not sure whether it applies naturally to the sort of classification you are referring to here. It seems that C# does not have an "official" term for that either.

Upvotes: 3

svick
svick

Reputation: 244777

If you want to know the official name, look into the official source: the C# language specification. Quoting from there (§1.3 Types and variables; emphasis mine):

There are two kinds of types in C#: value types and reference types. […]

C#’s value types are further divided into simple types, enum types, struct types, and nullable types, and C#’s reference types are further divided into class types, interface types, array types, and delegate types.

Then there is a table that describes those groups of types as category, and also this quote:

Five of C#’s categories of types are user-definable: class types, struct types, interface types, enum types, and delegate types.

Although later (in §4 Types):

The types of the C# language are divided into two main categories: Value types and reference types.

To sum up, the specification calls them categories of types, although its usage of that term is not very consistent.

Upvotes: 11

Related Questions