From: Gregory Seidman Date: 2006-09-22T00:59:04+09:00 Subject: Re: Ducktator - A Duck Type Validator On Fri, Sep 22, 2006 at 12:31:43AM +0900, Austin Ziegler wrote: } On 9/21/06, Gregory Seidman wrote: } >Actually, it is the developer's responsibility to override respond_to? when } >overriding method_missing. To do one and not the other is just sloppy. } } Maybe. I did point out that in my early days of programming Ruby, I } would implement one without the other. But simply doing a #respond_to? } check doesn't help you with arity checking, which matters as much as } the presence of the method itself. The best duck typing language I know of is the C++ templating language. When I'm writing the code all I have to think about is whether the arguments I'm passing can do the things the templated methods are asking them to do. The compiler verifies everything about arguments and return types. Even though I have the flexibility and simplicity of a duck-typed language I have a compiler to perform static analysis on the code and perform contractual enforcement. Ruby's dynamism gives me even more flexibility, but I lose that contractual enforcement by static analysis. It's true that respond_to? is insufficient because it doesn't give me arity, but it's better than nothing. I maintain that overriding method_missing without also overriding respond_to? is sloppy coding. } -austin --Greg