From: Rick DeNatale Date: 2007-10-23T00:25:55+09:00 Subject: Re: Conflicts between using respond_to? and extending Ruby On 10/22/07, David A. Black wrote: > What I've always called the soft/hard duck typing distinction isn't > quite the same as what you're calling the chicken/duck distinction, > though, in the sense that I rule is_a? and kind_of? completely out of > bounds as duck typing of any kind. Duck typing, as I understand it > from various writings by, and exchanges with, Dave Thomas, starts > where is_a? leaves off. respond_to? starts to enter the duck-typing > orbit, in the sense that at least it's focused on the object and its > capabilities, rather than its class/module ancestry (and that's the > most decisive line to cross). Since it still falls short of simply > asking the object to do something, I consider it a "soft" form of duck > typing. It's object-driven, but not atomic. One difference between kind_of? and respond_to? is that it's slightly more likely that a particular method or methods mean what the chicken typer expects when using kind_of? than respond_to?, since kind_of? is testing an implementation relationship, but that's by no means guaranteed. The notion of 'type' held by the user of an object is often more complex and or general than just being in a particular implementation hierarchy, or responding to a certain set of verbs at the lexical level. So I don't see so much of a distinction between respond_to? and kind_of? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/