dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (10/04/90)
I'm doing some work in TP5.5 on objects that are supposed to represent
mathematical functions such as polynomials and piecewise polynomials.
I'd like to do basic algebra on them, and have developed constructors
for each type that construct a new one as a sum or product of two others
of the same type, but I find myself wanting to work with both types together,
without going through the hassle of promoting my polynomials to piecewise
polynomials first.
My question is: has anybody else developed a general scheme within TP 5.5
for handling binary operations like this? I.e. if my object hierarchy was
math_function
polynomial
piecewise_polynomial
other
I'd like a
function math_function.product(term1,term2:math_function_ptr):math_function_ptr
method that would be able to invoke the
appropriate method no matter what the actual type of its arguments, and
return a pointer to a newly constructed object that's the product.
It would also be nice if I didn't have to change the definition of
math_function.product every time I added a new descendent. I wouldn't
mind some kind of explicit registration procedure if that's what I needed.
Duncan Murdoch
dmurdoch@watstat.waterloo.edu