From: Mathieu Bouchard Date: 2005-03-26T11:23:11+09:00 Subject: Re: Hash::MixIn and Python style Object#dict On Sat, 26 Mar 2005, gabriele renzi wrote: > Florian Gross ha scritto: > > Anyway, does any part of this look useful to you? > > I've heard quite a few requests for a Hash mix-in, but I'm not sure how > > to best make this available to the general public. > I'm starting to think we could have a RubyBase package on RAA to provide > lots of useful mixins (basically for fat classes i.e. IO::Readable, > IO::Writable, String::MixIn, Array::MixIn, but also for new things). > What do others think? MetaRuby (http://artengine.ca/matju/MetaRuby/) provides that, with examples implementing #undo/#redo, BitArrays, InstanceVariablesHash, MethodsHash, FileAsString, ProcAsArray, ... And those examples are all very short. Incidentally I have found that letting the user define #[] and #[]= is a bad idea because those methods are too complex (I mean those in Array and String) and instead I make the user implement #put, #put_seq, #get, #get_seq, for which I give extremely simple definitions. I also use a mixin-based contract together with a mixin-based implementation. I used to call it all ArrayMixin, HashMixin, etc., and later changed the name because people found it was a bad name, and the current names are worse because I confused two similar words in English (it's a bad idea to assume my English is excellent just because I use a lot of vocabulary: it's *not*). If I resume that project the names of the three containers will change again (but all the rest will stay essentially the same). _____________________________________________________________________ Mathieu Bouchard -=- Montr�al QC Canada -=- http://artengine.ca/matju