Functions add/diff/cmp for xtime

Markus Kuhn Markus.Kuhn at cl.cam.ac.uk
Fri Oct 9 09:23:18 UTC 1998


"Clive D.W. Feather" wrote on 1998-10-08 19:16 UTC:
> In message <E0zQZGb-0003Om-00 at heaton.cl.cam.ac.uk>, Markus Kuhn
> <Markus.Kuhn at cl.cam.ac.uk> writes
> >Several commentors have expressed a desire to have a few basic
> >predefined arithmetic functions on xtime values.
> >
> >I suggest to add the following three functions. These functions are so
> >simple that I feel the easiest way of specifying their behaviour is by
> >providing a sample implementation (i.e., using C as the specification
> >language instead of English):
> 
> Sorry, but if they're that simple, why bother ?

1) Because much more than one commentor requested them.

2) Because they can be expected to be present in higher programming
   languages with operator overloading anyway, and for the people who
   develop these bindings, it will be helpful to have some guidance
   regarding the semantics.

3) The implementation certainly is trivial, but the semantic in the
   context of leap seconds has cost me a few hours of scratching my head
   before I got the ones with which I am happy now. I did throw away a
   number of alternative functions that did not result in the nice
   algebraic properties and in the consistency with the TIME_UTC
   model that the ones I proposed now have (see the assertion).

4) The functions are useful for discussions about the API, as they allow me
   to quickly write down algorithms based on this API (see my previous
   postings where I did already use them)

I believe that there is some expert insight in the selection of
these functions and that the majority of programmers might get less
favourable functions if they are given 10 minutes to write them.

The operator overloading in a C++ or Ada API will probably be more
orthogonal and complete and will also include functions that replace the
double by xtime, but given the presented functions, the semantics of
these additional operators should be very clear and obvious, therefore I
did not suggest to add these as well to the C API. Since there is no
operator overloading in C, there is the danger of overwhelming the user
with too many functions if you provide full orthogonality through all
possible type signatures (double, xtime, int, etc.). C is a bit too
primitive for designing really nice APIs.

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




More information about the tz mailing list