""" Getting back to real math, we're talking extensible type system, with primitives, all objects if you like, but with methods, not just state.
And so therefore:
>>> 1 .__add__(1) 2
where a dir(1) -- dump of the number one instance -- gets you a list of integer type methods, inheriting from 'object' above that. There's a canonical class type in Python, but you're welcome to design your own metaclasses.
To just define a new ordinary class, do something like:
class Dog(object): def __init__(self, a,b): self.a = a self.b = b def __repr__(self): return 'I'm Dyadic Dog (%s, %s)' % (self.a, self.b)
And so on.
[End of 7th grade lesson plan.]
Then, as high school progresses, we'll describe types in terms of their methods and properties. For example integers have this property 'sign' whereas rationals have these properties 'numerator'/'denominator' and/or 'dividend'/'divisor' (these being in turn of integer type). However, as both are numbers, they inherit an interface consisting of + - * and / (add, subtract, multiply, divide). That's a minimalist 'number API' if you will. Not that all math types obey it. Vectors, for example, haven't multiplied directly, only added and subtracted, after scaling (e.g. float * vector). Different algebra. Same general idea (groups, rings, fields and like that).
Then Hamilton came along with quaternions, which behaved a lot like vectors, yet multiplied directly, in ways relevant to 3D game programmers. Quaternions. To be watered down (thankfully) by Heaviside and Gibbs. Gibbs had an especially good feel for how to teach vectors. We thank him for that. The others too. Vectors useful. Quaternions useful. Cave paintings useful.