Is there a term for regular variables, as opposed ...
# getting-started
e
Is there a term for regular variables, as opposed to type variables? I want to make a slide showing the differences and similarities between these two categories of variables.
s
What do you mean by type variables?
e
I'm introducing generics, such as List<T>, where T is a type variable.
s
Ah, I think most folks (in java/kotlin-land) refer to them as type parameters to avoid confusion
actually, looking over the Rust and Swift docs, that seems to be the accepted nomenclature across a few statically-typed languages
I think the big difference is just that variables represent data or values, whereas type parameters represent types, which are assemblages of rules that define or at least constrain the representation and content of discrete groupings of data
🙏 1
y
In the compiler, normal parameters are referred to as value parameters to contrast with type parameters. Same thing with value arguments vs type arguments
s
Another distinction is that type parameters are not valid l-values, that is to say, they can't really be assigned to like you can with regular variables. You can't write a line like
T = String
or anything. You can define constraints (
T : CharSequence
for example) but that's not the same as actually assigning a value to a symbol