From: gotoken@... (GOTO Kentaro) Date: 2001-01-08T08:54:52+09:00 Subject: [ruby-talk:8800] Re: No :<, :>, etc. methods for Array In message "[ruby-talk:8797] Re: No :<, :>, etc. methods for Array" on 01/01/08, "Christoph Rippel" writes: >My secret wish for 1.7 would be the creation of a parallel (for >legacy reasons) more fine grained collection class hierarchy instead >of the current everything is either an ``Array or Hash'' strategy, >in which Arrays can take on the roles of Sets, MultiSets, Numerical >Arrays, Stacks, etc. . Introducing specialized collection classes >could make Ruby more efficient, clearly expresses the indent of usage >and could provide a definite answer on whether a general #sum method >should be included or what the proper definition of the intersection >of arrays should be ... . I think such collections can be implemented as extension libraries if one needs efficiency. Maybe designing interfaces is too difucult for built-in specialized collections because we are greedy, and must want many special methods for each of them, but our taste are more different in case of special cases than in the general case. I have such experience in the development working of NumArray (in RAA). >> def sum(if_empty = 0) # Is the integer zero suitable? >An alternative would be the introduction of a ZERO and ONE constants >in the Numeric class (possibly overridden in subclasses)? Because sum is defined in the context of container class, such constants have to be given with their scope. However, ONE and especially ZERO sound interesting. They will reduce magics in code, perhaps. -- Gotoken