If I'm following this correctly, shouldn't we just say that Duration
does Num?  That way, a Duration can be used exactly like a Num is
(with units measured in seconds); but it could also have special
capabilities above and beyond what a Num can do, if such capabilities
are needed.

More generally, I wonder if maybe we _should_ provide a tool to help
with dimensional analysis: a role that does Num, but also tracks the
units for you.  The simplest version would leave it up to the
programmer to handle unit conversions (e.g., divide a Dimensional that
uses the "seconds" unit by a Dimensional that contains 86400 for its
value and "seconds/day" for its units to get a Dimensional that uses
the "days" unit, rather than providing built-in unit conversion
routines).  Indeed, th simplest form of Dimensional ought to be able
to work with arbitrary units.  The idea here isn't to place
limitations on anything, but rather to make it easier to track
additional data that's relevant to the calculations being performed.

With this in place, Duration would be synonymous with "Dimensional,
measured in 'seconds'".

That said, it's possible that this would open up a can of worms.
Would it?  If so, it can be postponed; Perl 6 has this nice little
versioning ability that lets us retroactively alter roles; so one
could easily put together a Dimensionality module at a later date that
redefines what a Duration is.

-- 
Jonathan "Dataweaver" Lang

Reply via email to