From: "Florian Groß" Date: 2005-04-04T09:39:05+09:00 Subject: Re: Hash::MixIn and Python style Object#dict Mathieu Bouchard wrote: >>But I wonder: why both you and florian considered the need to have >>contracts for this mixable things? > > Because it helps distinguish responsibility in case of incorrect > behaviour, so that a bug can be located more easily. There's a similar > argument in favour of type-checking in general. > > A way of working that many duck-typers have adopted is to just ignore > those things, so that all failures happen at the lowest possible level > instead of the highest possible one, producing error messages that are > meaningless in terms of the highest-level. Somehow they treat this as a > nonissue (and I don't want to speculate on why that is). One thing I don't quite like about duck typing is that is applied where it does not make sense to apply it. Even the "If it quacks and walks like a duck it can be handled like a duck" is an odd one. First of all duck typing never checks the "like a duck" part. It also isn't correct to handle something that does a few things like a duck like a duck. You can handle it like something that does a few things like a duck. That's all you know. The other area where I feel it is getting misused is calling .respond_to?() duck typing. I think that duck typing has always been about not checking, but rather just doing. I guess views will widely differ on this subject and I'm not even sure if there is one authorative source that could clear all these different interpretations up...