Yukihiro Matsumoto <matz / ruby-lang.org> wrote: > Hi, > > In message "Re: Range behavior (Re: [RCR] New [] Semantics)" > on Wed, 6 Oct 2004 22:58:35 +0900, "trans. (T. Onoma)" <transami / runbox.com> writes: > > |Not at all. This is something particular to a Range so why overload #include? > |with that function? Doing so can cause duck-typing problems. To me member? > |and include? are just different names for the same thing and should stay that > |way. > > Your opinion makes sense. What do you thinks is the best way to fix? > Or maybe we first need to define the problem to fix to evaluate the fix. If I've followed along properly, the problem is as follows: Enumerable sets up a contract that include? is a synonym for member?, in much the same way that map? is a synonym for collect?. By changing one but not the other, Range is breaking that contract, which might affect duck typed code. (Incidentally, I see this as an excellent argument against having "officially blessed" synonyms at all, but that's another argument.) Of course, the underlying problem may be that range should not include Enumerable at all, or that ContinuousRange and DiscreteRange should be two entirely differnt objects, with only the latter including Enumerable. Then we could have a separate RangeLike mixin, with a contains? operator that does bounds testing, and the DiscreteRange would mix in Enumerable and hence get include? (and member?) with discrete semantics. Separating Range functionality into a mixin might also make it easier to get goodies like negative-stepping and infinite ranges. martin