3 ms·
To a first approximation, a type is an equivalence class of expressions such that the set of valid programs is closed under substitution of one of these express
by edflsafoiewq 9y ago
To a first approximation, a type is an equivalence class of expressions such that the set of valid programs is closed under substitution of one of these expressions for any other (compare with the definition of a part of speech in grammar). In a typical dynamic language, anywhere the syntax requires an expression, any expression will do, so there is only one equivalence class.
This is in contrast to, say, Java, where (2/3) can be part of a valid program, but ("abc"/3) cannot, so 2 and "abc" cannot belong to the same equivalence class.