Hacker News new | past | comments | ask | show | jobs | submit login
Where does the T, U, V convention for generic type params come from?
4 points by bcherny on June 16, 2017 | hide | past | favorite | 1 comment
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?




I found out some old documentation introducing generics to C# 2.0 (source: 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.ht...).

Hope it helps.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: