3 ms·
OCaml has duck typing for objects (strictly speaking it is "structural typing").
by rwmj 11y ago
OCaml has duck typing for objects (strictly speaking it is "structural typing").
- nrinaudo 11y agoOh, right, I never realised that structural typing was static duck typing! Scala has it too, even if it's frowned on. Thanks for enabling me to make the connection!
- coldtea 11y agoDoesn't Go have the same thing?
- nrinaudo 11y agoI know next to nothing about Go, but I think you're referring to the fact that it has some sort of implicit inheritance resolution - if there is a Reader interface with a read method, and a type A that has a read method with the same signature, then A will be considered to be a subtype of Reader, whether you marked it as such (or whether you want it or not). I see what you mean, this feels like a static version of duck typing. I'm not sure how I feel about loosing control over what supertypes my type extends, though - well, I lie. I don't like it. But I haven't given this enough thought for a constructive, well argumented discussion on the topic.
- coldtea 11y ago>I'm not sure how I feel about loosing control over what supertypes my type extends, though - well, I lie. I don't like it. Well, don't you lose that by default (and even more) with dynamic typing?
- nrinaudo 11y agoYou do, and I really, really dislike doing any serious work without a solid type system.