-
Notifications
You must be signed in to change notification settings - Fork 16
Types, type factories, schemas, ...
TypeVariables associate any expression in a program with a type (or more precisely, a TypeInfo).
Some parts of the program do not have the same type each time they are used, for example the method filter
in collections can be of type Set<Number>
in one usage and Set<String>
another time.
Therefore, these kind of expressions can not have a unique type variable: each collection has its own type variable for its elements. This kind of expressions are annotated with a TypeVariableSchema, which will responsible fore creating a type variable each time it is used.
The process of creating a type variable out of a schema is named instantiation.
How and when a new type variable is created (i.e. if a new use should have a new type variable or reuse an existing one) will depend on the kind of schema.
TypeVariables and TypeVariableSchemas are used polimorphically in some places, through the ITypeVariable interface.
Schemas can be simple or compound. Simple schemas reference just a type parameter, such as the E
in List<E>
. When instantiated, they will produce a unique type variable.
Un esquema compuesto es el que al instanciarse produce un tipo genérico, es decir, que incluye type parameters, por ejemplo List o { A => B }.