"Christoph Rippel" <crippel / primenet.com> writes:

> > How would you do that?
> 
> This is pretty awkward within Ruby.  The first parts describes a (semi)
> solution for an individual class  -  the parsing rules of Ruby seem to
> imply that a plain "sym=  l"  is  never interpreted as "self.sym=(l)" .
> Maybe
> it is possible to change the parsing rules a bit so that  sym= x is
> interpreted as "self.sym=  l"  and/or make the __this__ pointer
> superfluous all together?  The second part is the automated version ..

I have to admit I got confused following all this through, but what
does __this__ do?


   class Class
     def attr_dave(name)
        attr name
        class_eval %{
          def set_#{name}(val)
            @#{name} = val
          end
        }
     end
   end

   class Fred
     attr_dave :test
     def check
       set_test 123
     end

   end

   f = Fred.new
   f.check
   f.test   #=> 123


Dave