Chris Smith wrote: > Marshall <[EMAIL PROTECTED]> wrote: > > Ouch; I have a really hard time understanding this. > > > > I can't see how you'd call + on a and b if you think they might > > not be numbers. If they could be something other than numbers, > > and you're treating them as if they are, is that sort of like > > doing a case analysis and only filling in one of the cases? > > If so, wouldn't you want to record that fact somehow? > > The obvious answer -- I don't know if it's what Pascal meant -- is that > they might be 4x4 matrices, or anything else that behaves predictably > under some operation that could be called addition. As a mathematical > analogy, the entire mathematical field of group theory comes from the > idea of performing operations on values without really knowing what the > values (or the operations) really are, but only knowing a few axioms by > which the relationship between the objects and the operation is > constrained. > > [As an interesting coincidence, group theory papers frequently use the > addition symbol to represent the (arbitrary) binary relation of an > Abelian group. Not that this has anything to do with choosing "+" for > the example here.]
Sure. This is what abstract algebra is all about; group theory is just an example. In particular, much of Stepanov's life work has been developing abstract algebra within the framework of a static type system. http://www.stepanovpapers.com/ In particular, see the paper "Greatest Common Measure, the Last 2500 Years." > Programming languages do this all the time, as well. The most popular > example is the OO sense of the word polymorphism. That's all about > being able to write code that works with a range of values regardless of > (or, at least, a range that less constraining than equlity in) types. Exactly. Marshall -- http://mail.python.org/mailman/listinfo/python-list