Jean Abou Samra <j...@abou-samra.fr> writes: > Le 05/06/2022 à 14:36, David Kastrup a écrit : >> Something like ly:moment-add has fewer implied semantics than + . Not >> just for humans (who expect + to be more-or-less commutative and >> associative even though the latter is only approximately the case with >> floating point arithmetic) but even for Scheme which extends a two-term >> definition of + into + with an arbitrary larger amount of summands. > > Wouldn't the same concerns apply on the C++ side, though? > I mean, Moment already implements operator+ etc., and C++ > understands a + b + c as (a.operator+(b)).operator+(c). > How would the C++ side of things be refactored if a distinction > between points of time and time spans is introduced?
There is a slight difference in that C++ does not have something like (- a b c) where an operator can cover an arbitrary number of terms (and the compiler chooses to apply it multiple times on its own). There is also a difference in that the C++ realm is behind a much taller barrier to the average (and non-average) user than the Scheme realm is and thus there is less incentive to accommodate "naïve expectations" to the same degree. So I'd say that would be a different discussion. Not that I'd be particularly looking forward to it. -- David Kastrup