From: Oliver Bandel Date: 2006-08-22T17:20:24+09:00 Subject: so called "duck typing" vs. FP (Re: Strategy pattern / interface design arrangement) Phrogz wrote: > Oliver Bandel wrote: > >>But maybe this analogy is not quite right... >>...so if someone is here who can explain it better... >>...if not, after jumping into Ruby more detailed, >>I may do it later. > > > Perhaps read the article that you cite: > http://talklikeaduck.denhaven2.com/articles/2006/07/26/my-favorite-duck-typing-story > > [...] This kind of texts has a lot of words but it makes the things not really understandable. Maybe because I don't see the problems as problems, because I look different on these things. So I like to hear that short story: > The short of it is: two different classes of objects are > interchangeable if they both support the same (named) methods that code > using those objects invoke. You don't need static-typing or > compile-type checking. You don't need interfaces. You don't need > contracts. You just need to have the methods available that you are > going to call. > OK, if that's correct, then duck-typing is different from FPL's approach. When you have the same types in a functional setting, e.g. with OCaml, then you can put together the functions, even if they have different names. As long as the type is the same, you can use them. The name can be the same but also be different. In OO there muste be the same names also. But what if the name is the same but not the type? It can bring a lot of chaos.... Ciao, Oliver