On 20.09.2006 10:58, MonkeeSage wrote:
> Robert Klemme wrote:
>> I do not think that the use of respond_to? is a regular duck typing
>> technique.  As Eric put it, respond_to? is exactly not applied regularly
>> when duck typing.
>>
>> Don't get me wrong, I don't say your lib is useless (in fact I envision
>> numerous uses for test cases etc.) but I think this claim of yours is wrong.
> 
> Not to push the issue, but Wikipedia seems to think that this is a
> valid claim [1]:
> 
> "[...A]n object having all the methods described in an interface can be
> made to implement that interface dynamically at runtime, even if the
> object's class does not include the interface in its implements
> clause. It also implies that an object is interchangeable with any
> other object that implements the same interface, regardless of whether
> the objects have a related inheritance hierarchy."
> 
> respond_to? in ruby is just a dynamic way of checking that "an object
> is interchangeable with any other object that implements the same
> interface".

The article does not claim that a client needs to check this.  And in 
Ruby you generally do not do that either, you just use it.  It just 
states that it's possible for an object to /dynamically/ implement a 
certain interface although it is not declared.

> [1] http://en.wikipedia.org/wiki/Duck_typing

Kind regards

	robert