In a language, some types are actually type variables. I am aware of three kinds of type variables:
- Generic Parameter Types: In the declaration of
Foo<T>
, theT
is a type that is a variable. - Associated Types: In languages like Scala, Swift, and Rust, a trait/protocol can have an associated type
trait Foo { type T; }
. Again, in the declaration ofFoo
, theT
is a type that is a variable. - Self Types: In Swift and Rust, the type
Self
is a type variable.
What is an umbrella term for all types that are not type variables?
OR
What is an umbrella term for reference and value types that are not type variables?
(I need a short way to refer to these in my compiler and language spec.)
EDIT:
It appears many people misunderstood my question in a way I hadn't anticipated. I was trying to keep the explanation of type variables short because it wasn't the core of the question. It is just background information. However, that led to the confusion.
When I said "in the declaration of," I meant in the scope of the declaration of that thing. Let me try to clarify.
- Generic Parameter Types:
public abstract class Foo<T>
{
// Here T is a type, but not a specific one. It is a type variable.
public abstract fn test() -> T;
}
- Associated Types
public trait Foo
{
public abstract type T;
// Here T is a type, but not a specific one. It is a type variable.
public abstract fn test() -> T;
}
- Self Types
public abstract class Foo
{
// Here Self is a type, but not a specific one. It is a type variable.
public abstract fn test() -> Self;
}
My language is an OO language in the style of Swift, C#, Java, or Scala and has all three of Generic Parameter Types, Associated Types, and Self Types. It also has abstract classes.
An example of how I want to use this term:
In the compiler, I have a class hierarchy that represents types. Simplifying some, there is a class Type
with a tree of subclasses including ones like OptionalType
(i.e. x?
), NeverType
(i.e. the bottom type), SimpleType
(i.e. primitive types), ValueType
(i.e. like the types declared with struct
in C#), ReferenceType
, and GenericParameterType
. There is a part of the heriarchy where the "type variables" split off. They have a lot in common and have a base class TypeVariableType
🤢. They can have constraints on the type but they have no actual properties. The other types, the non-type-variables also have a lot in common. I want a superclass for them. I need to name that superclass.
One answer brought up the term "ground type". That isn't what I am describing here. If test()
above returned List<T>
, that would be a non-type-variable type in my schema. That is because List<>
is a reference type.
I am expecting this term to also be helpful in the language spec.
TypeVariableType
? Continuing my analogy, that would almost be like having a specialIntVariable
type/property that would apply to expressions likex
but not tox + 1
or7
orf(y)
(wheref
gives back an integer). That would seem to be kind of complicated and it's not clear to me what the benefit would be. Can you elaborate on the benefits you want from it? Maybe my analogy is misleading in someway? $\endgroup$NonTypeVariableType
. Alternatively, "constructed type" (note that even nullary types are considered zero-argument type constructors, and tuples and functions are also type constructors). $\endgroup$