Moritz Lenz wrote:
> Am 17.11.2010 17:50, schrieb Jon Lang:
>> More generally, I wonder if maybe we _should_ provide a tool to help
>
> I think this question can only be answered in a meaningful way if somebody
> actually implements such a thing as a module (which should be entirely
> possible in Rakudo right now). Then we'll see if people take it up and use
> it.
>
>> That said, it's possible that this would open up a can of worms.
>> Would it?
>
> Another reason to prototype it as a module.

Agreed.  I'll look into writing something up.  That said, I'm short on
time, so don't hold your breath waiting for me to do it.

I've been thinking about this some more: perhaps the dimensionality
feature, if included at all, should be done as a trait; e.g., "5
seconds" would be C< 5 but units("sec") >, or something to that
effect.  That way, you could easily add units to Num, Rat, Int,
Complex, or anything else that could reasonably be dimensional, and
they would continue to be usable in their original context.

With respect to Instant and Duration, my gut instinct would be to
change things so that in the default Perl setting, Duration goes away
and is replaced by Num; but the Dimensionality module would modify
Instant to be aware of units, and to act accordingly (e.g., Instant -
Instant returns Num but units("sec"); Instant + Num looks for units on
the Num and throws an exception if it finds the wrong ones, or none).
If you don't want to bother with dimensionality, use the standard perl
setting; if you want perl tracking these things for you, "use
Dimensionality".  In short, take Duration out of the default setting,
but make its added functionality available by means of a module.

-- 
Jonathan "Dataweaver" Lang

Reply via email to