John Macdonald wrote:
... (and there may be additional
operator attributes that make sense there too, although none
come immediately to mind).

Well, I wonder why people neglect the fact that the neutral/identity element is not a property of the operator alone?! Besides the associativity and commutativity of the operator the inverse element---or the left and right one---with respect to the underlying representation come at least to my mind :)

This would give an "axiomatic" type system:

class Num does Group[Num,+,0]     {...}
class Num does Field[Num,+,0,*,1] {...}
class Str does Monoid[Str,~,''] {...}

class Complex does Field[Array[2] of Num,+,[0,0],*,[1,0]] {...}

class 3DVector does VectorSpace[Array[3] of Num,+,[0,0,0]] {...}

And it provides valuable information to the optimizer.
--
TSa (Thomas Sandlaß)



Reply via email to