From: Its Me Date: 2004-03-03T13:54:46+09:00 Subject: Re: UnboundMethod#hash apparently broken in 1.8.1 "Yukihiro Matsumoto" wrote in message > Why not? The UnboundMethod object is a wrapper of the internal "real" > UnboundMethod. A wrapper does explain it; but see below why I think it would be useful otherwise. > I thought UnboundMethod is not THAT important to pay > the price to satisfy your expectation. I don't know enough to understand the implementation trade-offs. But uniform access to the meta-level could be very good. I want to build a facility to attach meta-data easily to (meta)objects. Along the lines of the new @meta-data in Java 1.5, or the attributes in C#, but exploiting Ruby's flexibility. I want to use this facility to capture structures that describe properties of modules, classes, attributes, methods, formal parameters, exceptions, relationships (even if implemented as attributes), ...etc. These structures may be interpreted, used to generate code and other artifacts, used transiently or kept around for a while, used to hook in compiler extensions, etc. Simple examples of properties: - R vs. R/W attribute - Computed vs. Stored + auto-updated attribute - Types of parameters and attributes - Documentation (!) - Various propagation properties of relationships I know there are several reasons why the following won't work today in Ruby, but here is one sketch: --------------- class Class; def META ... end; end class UnboundMethod; def META ... end; end class Attribute; def META ... end; end class Param; def META ... end; end # of course, could be more varied than single META method --------------- class A META meta_data_on_class_A # assume self =A attribute a1 META meta_data_on_attribute_a1 # build Attribute object, attach meta_data # generate r/w methods # assume (attribute a1) returns Attribute object def foo (p1 META meta_1, p2 META meta_2, ...) # assume Param objects accessible in parameter list # perhaps "," operator builds up param list end META meta_of_foo # assume def...end returns UnboundMethod end But then I'm a relative ruby nuby ...