From: David Alan Black Date: 2002-02-14T08:47:40+09:00 Subject: Re: qualms about respond_to? idiom Hello -- On Thu, 14 Feb 2002, Matt Armstrong wrote: > David Alan Black writes: > > > Hi -- > > > > On Thu, 14 Feb 2002, Dave Thomas wrote: > > > >> module StartTag; end > >> > >> Then we have > >> > >> do_somthing if e.kind_of? StartTag > >> > >> Does that communicate the intent? > > > > Isn't it a return to branching on type, though? > > Using respond_to? is a form of branching on type in any case. using(respond_to?).kind_of?(Branching::OnType) # :-) I don't think I agree that this evaluates to true, though.... > Dave is using a module to communicate that a particular class conforms > to a particular interface -- which allows the use of kind_of? to test > for the interface. Yes, that's clear. My point was just that my original use of respond_to? was as an alternative to type-based heuristics, so using kind_of? seemed like we'd come full circle to the thing I'd been trying to avoid. I'm not as doctrinaire about it as I probably sound :-) but I do like the idea of a kind of per-object/interface logic; I just don't like the repetition involved in the respond_to? idiom. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav