On Wed, 5 Oct 2005, TRANS wrote: > On 10/4/05, Mathieu Bouchard <matju / artengine.ca> wrote: > > class Module;attr_accessor :doc;end > > Fixnum.doc||={} > > Fixnum.doc[:+] = "addition" > Right. That works well. It's just that methods are generally referred > to by the symbol, like with method_missing and all. So it seemed > reasonable. (I had original created a FirstClassMethod manager module, > but decided it was too heavy, so Symbol sort of took it's place.) But > you're right. This is better. Attaching methods to symbols isn't that bad, it's just not Ruby's way of working. In Ruby, methods are located first by the module/class and then by the selector symbol. In Lisp, for example, it would be the other way around, as (defmethod foo ...) aggregates methods called "foo" of all classes under the same symbol foo. In either case, you have more than one level, so you are still stuck with using hashtables to hold the per-method information: in Ruby, once you're in the right class, you have to make yourself something to distinguish between methods of the same class, and in Lisp, once you're in a Symbol, you have to use (nested) hashtables to distinguish between methods of the same name. Then if you have several pieces of metadata, e.g. doc, sig, flags, you can handle this whatever way you want. making a FirstClassMethod class is a possibility; making three hashes per module/class is another possibility. Whichever fits you. ____________________________________________________________________ Mathieu Bouchard - tñÍ:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, MontrñÂl QC Canada