Carl Sorensen <[email protected]> writes: > On Fri, Jun 3, 2022 at 7:21 AM David Kastrup <[email protected]> wrote: > >> Dan Eble <[email protected]> writes: >> >> > On Jun 2, 2022, at 20:32, David Kastrup <[email protected]> wrote: >> >> >> >> #(define-method (+ (a <Moment>) (b <Moment>)) (ly:moment-add a b)) >> >> #(define-method (- (a <Moment>) (b <Moment>)) (ly:moment-sub a b)) >> > >> > Could we also introduce a distinction in type between points and spans >> > of time? "Measure 12 minus Measure 8" is 4 measures, but it is not >> > Measure 4; and "Measure 12 plus Measure 8" is not a thing. >> >> While I get your point, I think that this ship has sailed. That's not >> as much a problem of GOOPS but of the preexisting code. >> >> I think the first point of cleanup would be to replace Moment's misuse >> as a substitute for "Rational" (which did not have a Scheme >> representation and was done at a time where Guile did not have >> "arbitrary" precision rationals), like in baseMoment. >> > > I think that baseMoment is exactly the kind of use that that Dan is > addressing. > > baseMoment is a "Moment Span", that is, a separation between two distinct > moments in time. > > I think that we need the concept of a Moment Span. Although it can be > represented as a Rational (as long as we ignore the Grace part),
A base moment has no grace part: that would be an utter absurdity. Your willingness to ignore this aspect of the type while wanting to stress that it is inherently a period size makes obvious that this is more of a picked academic issue than anything else. > just using a Rational does not carry the semantics of a Moment Span. Programming languages don't offer different types for distances, positions, weights, forces, whatnot. When I equate various amounts of power, the numbers don't demand that I get every part of 1 kg m²/s² = 1 V A s signed off by the compiler. I can rearrange terms perfectly well from a + b - c = a - c + b = (-c) + b + a without worrying about order of execution to make sure that every intermediate term has a well-defined physical meaning. > As I see it, a Moment represents a span from time 0, with the time 0 > being implied. It seems like we ought to be able to represent a > moment span as a pair of Moments. Frankly, that's academic. It reminds me of the excessive amount of energy placed into keeping the mathematics(!) of location vectors and difference vectors separate. Just as a reminder: we have functions ly:moment-mul and ly:moment-div and ly:moment-mod . In terms of being a logical atrocity, they certainly beat hollow the "problem" of not inventing a different type for time spans from arbitrary positions than for time spans from ZERO_MOMENT . -- David Kastrup
