David Alan Black <dblack / candle.superlink.net> wrote: > >On Mon, 8 Jan 2001, Ben Tilly wrote: > > > In your book I count 40 methods for hashes. Matching the > > full behaviour of arrays would be worse. > >Ummmm, not my book. (Which is called "Law in Film" -- hey, I never >thought I'd have an excuse to plug it here :-) Other Dav*. Or, >more precisely, one of the other Dav*s. (I guess I should find some >comfort in the fact that even being named Clemens doesn't help you >around here :-) Erk. Oops. > > Tying out to the full behaviour takes a lot more work than > > it needs to. A few well-chosen modules could make this > > much easier. > >But not every method would need to be redefined for every tying >situation. Again, I'm not objecting to the idea of some kind of >modularization of this, though I am having some trouble thinking of >a case where I would find it insufficient to redefine a few things >like #[], #[]=, possibly has_key?, etc. The idea of tie is to have a totally new implementation that happens to have a similar interface to something native. Given that you want to have a new implementation, you cannot inherit from the existing one. Therefore you either implement some minimal subset of the existing one, or else you do rewrite a lot of (admittedly not complex) methods. Many of which exist to be syntactic sugar. For new code you can just use the subset. Where tie becomes very handy is when you want to take a large body of existing code, not have to look at it, but still temporarily replace the implementation. >I'm willing to be persuaded, just currently see this as a solution in >search of a problem. > It is the same problem that Enumerable addresses. Turn building a complex and widely used interface into building a rather small interface. Many of the methods that are in Array and Hash today are there as either syntactic sugar or for convenience. Why not make it easy for others to reuse the convenience of that interface? Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com