>>>>> "Bill" == Bill Kelly <billk / cts.com> writes:

    Bill> From: "Mathieu Bouchard" <matju / sympatico.ca>

    >> On Mon, 30 Jul 2001, MikkelFJ wrote:
    >> > Eventually, I landed on OO shapes examples:
    >> > http://www.angelfire.com/tx4/cus/shapes/index.html
    >> > Try compare Ruby with OCaml. OCaml is surprisingly compact.
    >> 
    >> Ruby's example could be more compact if it didn't carry all of this dead
    >> weight. The guy who wrote it didn't use the metaclass to implement a
    >> version of "attr" that would use the get/set naming convention, plus he
    >> didn't understand what "attr" is for anyway, because he'd define both
    >> #radius and #getRadius, and both #radius= and #setRadius.
    >> 
    >> I don't know many of the other languages -- there may be other
    >> suboptimal implementations but I wouldn't be able to tell.

    Bill> I put up a first pass at rubifying the code on a wiki page:
    Bill> http://www.foosenblat.org/cgi-bin/qwiki.cgi?RubyShapeExample
    Bill> (had intended to add this to the rubygarden wiki, but kept
    Bill> getting 'could not get editing lock' errors)

    Bill> Any further improvements would be most welcome - for now
    Bill> I've changed it to use attr_accessor and dispensed with the
    Bill> get/set style entirely.  Seemed acceptable to me (and
    Bill> somewhat typical, right?), however, I don't yet know how to
    Bill> use metaclasses to provide the get/set convention you
    Bill> describe(!)

Wow, that Shape example has really gotten some mileage out of it.  The
original page can be found at http://w3.one.net/~jweirich/oostuff .
Originally it was supposed to be a demo of how to do polymorphism in
C.  I posted the C and C++ versions and people started contributing
examples in other languages.

Chris Rathman was the most prolific contributer, learning just enough
of a new language to do the shape example.  At one point, Chris was
donating a new language version almost every day.  It's not surprising
the examples lack polish.

Guy Hurst provided an updated Ruby version sometime ago.  Both the old
and new Ruby versions are posted on my page (see above link).  You
might wish to compare your version with Guy's.

-- 
-- Jim Weirich     jweirich / one.net    http://w3.one.net/~jweirich
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct, 
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)