4 ms·
> A proper Ruby-ish type checker will need to be able to handle that, or it'll push people to write non-idiomatic Ruby. It probably won't be idiomatic (maybe j
by emodendroket 8y ago
> A proper Ruby-ish type checker will need to be able to handle that, or it'll push people to write non-idiomatic Ruby.
It probably won't be idiomatic (maybe just add interfaces?) but I think duck-typing is overrated anyway. Just because an object responds to a method doesn't mean it's going to do anything like what you expect. To take a contrived example, Array.Shift and Keyboard.Shift are probably unrelated methods.
- vidarh 8y agoYou don't have that guarantee with interfaces either - you're trusting that the developer isn't lying to you. My experience is that I've more often run into developers that have artificially barred me from doing what I wanted by checking for a given class, than that I've accidentally passed in something that satisfies a given type but does something different.
- klmr 8y ago> You don't have that guarantee with interfaces either True, but you can give the interfaces/contracts proper names (or namespaces). To use the example in the parent comment, `Array` and `Keyboard` wouldn’t implement the same contract even if both have a `Shift` method.
- emodendroket 8y agoI guess now that I think about it Scala does have a strongly-typed duck-typing thing, but it's kind of silly and rarely used.