3 ms·
available in most modern languages Well, "modern" is an ill-defined concept. As far as I'm aware, structural typing is not really that common, is it? Besides O
by icebraining 12y ago
available in most modern languages
Well, "modern" is an ill-defined concept. As far as I'm aware, structural typing is not really that common, is it? Besides OCaml and Scala, is there any relevant (used outside of academia) language that supports it?
- pjmlp 12y agoD and C++ templates for example. F# also supports it, given its ML linage. C# tricks with dynamic, although in this case it is dynamic typing, so not really the same thing.
- seabee 12y agoThe disadvantage of C++ templates is the structural type is implicit - you only know if the input object satisfies the type if you read the documentation, code, or can decipher the error message that occurs if it didn't. Concepts would have fixed this, but we don't have concepts and maybe never will!
- pjmlp 12y ago> Concepts would have fixed this, but we don't have concepts and maybe never will! enable_if and type traits are a workaround for the time being. Concepts lite will definitely be in the next revision.
- losvedir 12y agoWould rust's "traits" count as structural typing? (I know Rust may not count as "relevant (used outside of academia)" yet, but maybe in the future.)
- tel 12y agoHaskell's typeclass provide it.
- dragonwriter 12y agoTypeclasses aren't structural typing, they are nominative typing, as typing is controlled by explicit declaration of relations between types and typeclasses, not inferred from structural properties.
- tel 12y agoSure they are: (forall a. X a => a) is a supertype of (forall a. (X a, Y a) => a).
- dragonwriter 12y agoI stand corrected.