Concerning Time.TimeDiff

John Meacham
Thu, 19 Jun 2003 17:18:10 -0700

It is more complicated than that. for any representation which allows
denormalized values (as 2 numbers would), they would have to be
normalized before most operations. you cannot compare the numbers unless
you normalize them, plus every operation on them will have to check for
overflow of the picoseconds field to place it into the seconds field. it
would be a common source of errors and a pain to deal with correctly.
nothing is keeping anyone from implementing their own notion of time
based on Rationals and/or primitive numbers, if you only cared about
seconds for instance then perhaps an Int64 will be just fine, and you
can use that in your own code. we just need to provide some way to get
at the basic time functionality of the OS in some way that works (as
opposed to the current broken mess) and supply a few generally useful
functions to manipulate those values.

in any case, since a pair of Int64's is not a clear win and an Integer
definatly is a clear win in terms of usability then I believe we should
go for that. 

On Thu, Jun 19, 2003 at 04:51:08PM +0100, Alastair Reid wrote:
> On Thursday 19 June 2003 2:59 pm, Ketil Z. Malde wrote:
> > ...and I don't think it's entirely given that two 64 bit numbers will
> > be faster than one Integer.
> I do.  the implementation of Integer requires traversing additional 
> indirections to an array of bits, reading the size of the operands, 
> allocating space for the result, etc.  It's a lot of work even if the 
> arguments and result are simple values like 0 or 1.
> I suspect Integer could be optimized (by recognizing that most uses of Integer 
> are for values that fit in 31 bits) so that the difference is pretty minimal.  
> but this would have limited effect on a date like 19 June 2003 which is (very 
> roughly) 2^69 picoseconds since the epoch.
> Which is all to say that whatever sound reasons may exist, future portability 
> concerns or performance are not reasons to prefer using a single Integer or a 
> Rational.

John Meacham - California Institute of Technology, Alum. -