Hi Barney, > If anything I was thinking of recording the remainder in the the original > number object, not the one returned (or possibly in something like a WeakMap > keyed to it). So it does increase state and makes it technically no longer > immutable, but that change in state would not be detectable from outside > except by profiling performance. It's state that would have to be ignored in > the equality check.
I see, I understand. But I don't think that's wise. For example, if we reversed the order of the div and mod, there would be no cache and we wouldn't get the speed boost. (Or does it cache the quotient as well?) Also, even if the order is as expected, if another division is performed in between, the cache will be overwritten and it will become meaningless. The main concern is the cost of having to mod data during division for the surplus that we may never use. There is the issue of data capacity, but the extra processing such as memory allocation will inevitably occur, so for those who don't need mod, the change will make slow down. Regards, Saki