From: gabriele renzi Date: 2004-06-06T21:03:43+09:00 Subject: Re: How to ducktype a Hash? il Sun, 6 Jun 2004 18:52:44 +0900, Jeff Mitchell ha scritto:: >This is the fault of PStore or of the lack of agreed-upon semantics >for classes with hash-like behavior. There should be a standard list >which includes the definition of such behavior. Here, I'll start the >list now: > > hash-like: #fetch, #store >array-like: #at, #store > >Any others? How about tree-like? > >I want this list to be part of the ruby standard -- clearly >documented so that implementers know they should define #fetch >and #store for the hash-like classes they write. [] should >be viewed as convenience only. I may be wrong but what you're asking has been throw out many times. It would be wonderful to have stuff like this for everything, toghether with a possible mix-in. We have, actually, many 'default quacks' like :read and :write for IOs, :each for enumerables, and so on. Maybe adding some more mix-ins would be fine for many people's need (say, if a Map mixin existed, we could have it rely on fetch(),keys() and store() to provide all the other methods). This way hash-like stuff like PStore, will just need to include the mix-in and Sean could just check for kind_of? Map if he feels the need for this. Oh, and can I ask for an Input and Output mixin, while I'm at it ? :)