Hello Det,

Tuesday, December 17, 2002, 12:25:24 PM, you wrote:

D> the shortcuts  attr_<reader|writer|accessor> for
D> creating an instance variable with standard accessor
D> methods is one of the big features of Ruby in my eyes.

citating my earlier letter:

attributes is just methods, automatically defined by attr_reader/...
built-in methods. you can write such methods as attr_reader himself
and some advanced OO libraries actually do this. it's easy:

class Class
  def reader attr
    module_eval <<-END_OF_EVAL
      def #{attr}
        @#{attr}
      end
    END_OF_EVAL
  end
end

class A
  def initialize(x0)
    @x = x0
  end
  reader "x"
end

a1 = A.new(23)
p a1.x
a2 = A.new(34)
p a2.x


D> Is there a way to do something like:

D> class MyClass
D>       attrList_accessor :aRelation
D> end

D> to get the above ?

you can find examples of using *_eval to defining such metafunctions
in Pickaxe book. citating Pickaxe: "Understand this code, and you'll
be well on the way to true Ruby mastery." :)  see "classes and objects"
chapter


-- 
Best regards,
 Bulat                            mailto:bulatz / integ.ru