> -----Original Message----- > From: Ben Tilly [mailto:ben_tilly / hotmail.com] .. > Constructing Z/n is a special case of a generic > construction that you see in ring theory. The general > idea is that you take a ring R (eg Z), and a subring I > (eg the multiples of 5) with the special property that > anything in R times anything in I gives you something > back in I. You can now say that two elements x and y > are the same mod I if x-y is in I. Each equivalence > class can now be represented by a single element in R, > and the set of equivalence classes turn out to be a new > ring R/I. > > In my books a good model of Ring would be able to handle > this common and basic construction. That would mean > (for instance) being able to handle the idea that > evaluating x=5 can be done in Q[x] (the ring of > polynomials over the rationals) by modding out by the > ideal (x-5). (Ruby might do this, I don't know. But > to my eyes this is a statement of the general problem > that I see in modelling concepts like Ring in an OO > hierarchy.) Add Ben Quotients construction - that would be def Ring.quotient R, I end to be called as MyQuotRing = Ring.quotient R, I which would act like class MyQuotRing QRing = R QIdeal = I attr_reader :rep .... end A practical implementation of an ideal type generating class is another (non-trivial) matter. My point is that generic programming is a better mold than strict inheritance|mixing based OO-style programming when comes to describing modeling certain ``inherently typed'' (typed by construction) problem areas. Christoph ...