Dave Thomas wrote:

> 
> On Nov 7, 2004, at 8:05, James Britt wrote:
> 
>> And how can someone get
>>  attr_reader :foo
>>
>> to appear with the method definitions?
> 
> 
> Make it a method?   :)

I guess I've been under the impression that the attr_* methods did 
actually create methods.

> 
> It seems to be that if you're trying to save typing by entering
> 
>     attr_reader :foo
> 
> rather than
> 
>    def foo; @foo; end
> 
> you're giving up a fair amount of clarity in your source to save 3 
> characters. 

The example was short; in actual practice, there are often several 
method names:

attr_reader :foo, :bar, :baz, :blug

So the savings on typing goes up.

I don't see what clarity I'm giving up in doing this.

 > If it's a method, why not make it a method?

class Foo
   attr_reader :bar
end
f = Foo.new
methods = f.methods - Object.methods
p methods  # ["bar"]

Ruby seems to think I've defined a method.

If it's a method, why not document it as a method?

James