4 ms·
Where does the T, U, V convention for generic type params come from?
Java, C#, and TypeScript use T, U, V, etc. to represent generic type parameters. Ostensibly that's because T stands for "Type", and U and V follow T in the alphabet.
On the other hand, Scala uses A, B, C and so on, and OCaml and Haskell use a, b, and c.
Where do these conventions come from? Is it because the functional languages are closer to math proofs, where α, β, and γ are used by convention?
Does anyone know of an early mailing list, commit message, etc. where this convention was discussed?
- linkula 9y agoI found out some old documentation introducing generics to C# 2.0 (source: https://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx https://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).a...) where it is said, that <T> stands for "Type" (as you said in your question). I also looked at Scala's documentation and found out the following: "Generic classes take a type as a parameter within square brackets []. One convention is to use the letter A as type parameter identifier, though any parameter name may be used." (source: http://docs.scala-lang.org/tutorials/tour/generic-classes.html http://docs.scala-lang.org/tutorials/tour/generic-classes.ht...). Hope it helps.