To clarify, by "define particular methods" I mean that said 2 roles would
require composing classes to define them, not to include the code themselves. --
Darren Duncan
Darren Duncan wrote:
I think that "Instant" and "Duration" should simply be declarational
roles that don't have any implementation code to compose.
Composing "Instant" or "Duration" into a type simply says that the
objects of that type represent a point on a timeline or an amount of time.
Specific units, even "seconds" should not be mentioned at all in the
definition of "Instant" or "Duration"; instead, any particular units or
calendars or whatever would just be a property of the composing class.
Said 2 roles would *not* specify that values would numify or strify or
boolify in any particular way, such as seconds or otherwise; this is
strictly a property of the composing class.
Said 2 roles could define particular methods such as, assuming we're
just talking one-dimensional:
Instant - Instant --> Duration
Instant + Duration --> Instant
Instant - Duration --> Instant
Duration + Duration --> Duration
Duration - Duration --> Duration
Duration * Numeric --> Duration
Duration / Numeric --> Duration
Duration / Duration --> Numeric (rational in general)
Duration div Duration --> Numeric (integral)
Duration mod Duration --> Duration (rational in general)
I don't see that multiplying a Duration, or having arbitrary
exponentiation, makes any sense when talking one-dimensional, especially
when we're being completely units-agnostic. A specific implementing
type may have a concept of dimensionality, but I would think that these
2 roles don't.
Perhaps a suitable analogy is to look at the level of abstraction that
"Numeric" has relative to composing classes.
Do we want Instant and Duration to include concepts like dimensionality,
such as like Numeric may include Complex, or do we want it to explicitly
be one-dimensional (though units agnostic), like Real?
And whatever choice we pick, maybe there should be suitable generic
names given to the complementary concept of what I mentioned.
-- Darren Duncan