> It could be that this is totally the wrong thing. Is (* x 2) -> (+ x x) > a valid transformation if you don't know the type of x? I don't know. Only if both addition and multiplication are defined for the type. In a group-like structure there is only one operation, while ring-like structures have two (usually called addition and multiplication). All the numeric types included in Guile are ring-like, so that works fine. Outside of that all bets are off. What would transforming (* -1 v) to (- 0 v) mean? You cannot add or subtract scalars and vectors, unless you were to embed both into a field where they are both defined, like the quaternion field. Or you would have to use the zero-vector as the value of 0.
> WDYT? We could remove this transformation, or only apply it when type > inference has run. I don’t know. I guess there must be a good reason why Guile does these transformations, all I know is that they are not guaranteed to make sense outside Guile’s numeric types. Maybe it was my mistake for trying to make methods called * or + instead of making up my own names. The reason why I used those names (aside from simplicity) is that in those case it does make sense to mix multiplication of different types. I can write (* 2 3 q 4 5) where q is a quaternion and it will apply the correct operation to all operands, just as if I had written it on paper. It also allows me to use any type that implements * as the component of a dual number and have it work. If you can stop Guile from re-writing code when it is not certain that the rewritten code makes sense it would be great. Pretty much every test that I have written over the past few days was broken even though my math was correct.