From: Avi Bryant Date: 2001-07-25T14:32:24+09:00 Subject: [ruby-talk:18508] Re: OO question On Wed, 25 Jul 2001, Dave Thomas wrote: > Stephen White writes: > > > It would be nice if there was some way of showing the connection between > > "join" and "split", "pack" and "unpack" and other related operations even > > though they reside in different classes. > > I think this is an excellent thought. Logically, if not in actual > implementation, it would be fun to think of an orthogonal set of > capabilities that you can add to the language. For example, you might > logically say > > use 'byte_and_bit_access' // ok - bad name > > and String and Array would be augmented with unpack and > pack. Smalltalk always did this with categories - you can ask a browser, for example, to show you all the methods in a particular category, regardless of class. It's also fairly common to "file-in" and "file-out" by category. In Ruby, of course, it's quite natural to have a file which adds methods to several classes, so that require 'byte_and_bit_access.rb' would be fine right now, if the standard libraries happened to be modularized that way. RCR: add smalltalk-like categories to Ruby? This would involve, at the least, having every method know which category it belonged to, from which you could build searches for all methods in a particular category, etc. Avi