From: Paul Brannan Date: 2002-02-14T03:26:14+09:00 Subject: Re: qualms about respond_to? idiom On Thu, Feb 14, 2002 at 02:23:04AM +0900, Dave Thomas wrote: > But then that smells: we have a method that we never call, simply so > we can use it as a flag. Hmm, let's have a mixin called StartTag that > anything that is a start tag includes > > module StartTag; end > > Then we have > > do_somthing if e.kind_of? StartTag > > > Does that communicate the intent? Hmm, not by itself it doesn't. But I think if it were well-documented what the purpose of this mixin were, then it might properly communicate intent. We could even give the mixin the power to restrict who can mix it in. If we need to have a certain set of methods defined before we are allowed to mix it in, then we can do that (see http://rm-f.net/~cout/ruby/treasures/RubyTreasures-0.1/lib/hacks/safe_mixin.rb.html for an example). We could even do other weird things like require that the class the mixin is being mixed into define certain constants or require certain methods to have a particular arity. But maybe this isn't such a good idea, and is trying to build a nail to fit a hammer. All I know is that I haven't yet seen a solution to David's problem that I like 100%. Is there such a solution out there? Paul