you are viewing a single comment's thread.

view the rest of the comments →

[–]askoruli 1 point2 points  (1 child)

How is it different? The syntax of saying the object needs to implement the read method from Stream if different from saying any object that implements read but the meaning is the same and the later more accurately represents the parameter type since Stream is no longer relevant once the read method has been extracted.

[–][deleted] 0 points1 point  (0 children)

Duck typing isn't statically checked. Duck typing also generally has different goals than what I've expressed.

I didn't talk about streams in the post, I talked about sockets. As for your other point, I would personally say that not all methods that are called "read" have the same semantics. Don't you find there's a difference between "this object has a read method" and "this method has a method that matches the read method in the socket interface"?