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. I put up a first pass at rubifying the code on a wiki page: http://www.foosenblat.org/cgi-bin/qwiki.cgi?RubyShapeExample (had intended to add this to the rubygarden wiki, but kept getting 'could not get editing lock' errors) Any further improvements would be most welcome - for now I've changed it to use attr_accessor and dispensed with the get/set style entirely. Seemed acceptable to me (and somewhat typical, right?), however, I don't yet know how to use metaclasses to provide the get/set convention you describe(!) Regards, Bill