On Tue, 19 Aug 2003 23:18:38 +0900, Gavin Sinclair wrote:
> For instance, I consider this good style:
> class Example
>   attr_accessor :attribute
>   # ...
>   def attribute=(x)
>     # something special
>   end
> end

> It lets the reader know up front that they can use #attribute and
> #attribute=, and then it changes the implementation, which the casual
> reader doesn't need to know - do they?

Maybe. One thing that I've suggested to Dave for RDoc -- I haven't honestly 
been reading the Rdoc source to see if it's been done or how :) -- is that 
it might be nice to have something like:

  # Allows access to the +foo+ attribute.
attr_reader :foo

def foo=(x) #:attr_writer foo:
end

That way, RDoc could collapse the comments from _reader and foo= as if it 
were an attr_accessor. It would also make it relatively easy (IMO) to add 
additional "classes" that really do create specialised (but generated) 
attribute accessors. A bit more typing, but in this way, less code is 
executed by the interpreter (a good thing, IMO) while keeping the intent 
clear in the general flow and the documentation itself.

-austin
--
austin ziegler    * austin / halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.08.23
                                         * 19.13.18