Most users don't and won't know anything about "affine spaces" *per se*, however, it's not a super unusual relationship for two types to have. A few examples
Point2D and Vector2D Instant and Duration Pitch and Interval (i.e. music theory) If Java has operator overloading one day, I would feel it perfectly appropriate to apply it to these kinds of affine pairs-of-types. All of this to say that minus() is IMHO reasonable here. However, isn't until() just better anyway? Keeping the exprrssions in chrono order is nice, and I think everyone knows the order too (earlier until later). Whereas with minus it seems like you miiiight get it reversed. What am I missing? On Thu, May 2, 2024, 1:52 PM Louis Wasserman <lowas...@google.com> wrote: > That doesn't follow for me at all. > > The structure formed by Instants and Durations is an affine space > <https://en.wikipedia.org/wiki/Affine_space#Definition>, with instants > the points and durations the vectors. (An affine space is a vector space > without a distinguished origin, which of course Instants don't have.) It > is 100% standard to use the minus sign for the operation "point - point = > vector," even when "point + point" is not defined, and to use all the other > standard idioms for subtraction; the Wikipedia article uses "subtraction" > and "difference" ubiquitously. > > Personally, I'd be willing to live with a different name for the > operation, but consider "users keep getting it wrong" a strong enough > argument all by itself for a version with the swapped argument order; it's > not obvious to me that another API with the same argument order adds enough > value over Duration.between to bother with. > > On Thu, May 2, 2024 at 10:04 AM Stephen Colebourne <scolebou...@joda.org> > wrote: > >> On Thu, 2 May 2024 at 15:58, Kurt Alfred Kluever <k...@google.com> wrote: >> > instant − instant = duration // what we're discussing >> > instant + duration = instant // satisfied by instant.plus(duration) >> > instant - duration = instant // satisfied by instant.minus(duration) >> > duration + duration = duration // satisfied by duration.plus(duration) >> > duration - duration = duration // satisfied by duration.minus(duration) >> > duration × real number = duration // satisfied by >> duration.multipliedBy(long) >> > duration ÷ real number = duration // satisfied by >> duration.dividedBy(long) >> > >> > All but the first operation have very clear translations from >> conceptual model to code. I'm hoping we can achieve the same clarity for >> instant - instant by using the obvious name: instant.minus(instant) >> >> But you can't have >> instant + instant = ??? >> It doesn't make sense. >> >> This is at the heart of why minus isn't right in this case. >> Stephen >> > > > -- > Louis Wasserman (he/they) >