# Type Variables

Next: Functions, Previous: Variable Types, Index: Index

In addition to program variables, Mesham also supports type variables. Type variables are NOT runtime variables and do not appear in the resulting program. They are just limited to existing within the compiler during compilation and can be used within this context.
typevar [name];
typevar [name]::=[Type];
[type variable]::=[Type];
The first statement declares the type variable, the second statement combines the declaration and assignment and the third statement is type variable assignment - note the difference between normal variable assignment := and type variable assignment ::=

## Examples

typevar m::=Int :: allocated[multiple[]];
var abc:m;
var f:m;
typevar q::=declaredtype f;
q::=m;
In this example type variable m has the value Integer, allocated on multiple processes - which is used to in the declaration of variables abc and f. A new type variable q is introduced, with the value of the declared type of f. The type variable q then has the type stored by m assigned to it. Remember, type variables DO NOT occur in the resulting executable, they are only for the compiler.
Last Modified: August 2008