timedata-org / old-timedata

Time arts data - high-performance color processing in C++ and Python.
7 stars 3 forks source link

Make sure method names are consistent between `Color`, `ColorConst` and `ColorList`. #123

Closed rec closed 8 years ago

rec commented 8 years ago

Let's take a look at one of the "most general" operations: add.

Please note that this also has ambiguity we wish to get rid of - because adding for a Python list involves creating a new, longer list, whereas the operation we're most interesting in is arithmetic addition.

We need to keep the Python list semantics while keeping the actual symbol add for addition.


Question 1:

Right now, you can say Color.by_name.red * 0.75 - so Color doesn't look like a tuple when it comes to * and + and arithmetic works neatly.

If we lost this, we'd be more consistent between Color and ColorList Color looks "very much like a tuple", except for this one detail.

Now we'd have to say: Color.by_name.red.mul(0.75) - not so bad really.

OK - done deal I think. That means that almost all of the magic methods goes away except for two adds and two muls (one each in the case of ColorConst).


So we then have these possible forms of this function:

I like this. Very clear!