OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] limits of the generic

[ Lists Home | Date Index | Thread Index ]

Hi Jeff,

> I think you've hit the nub of this issue.  We expect '+' to be commutative,
> associative, and have additive inverses.  At least associativity and
> additive inverses have been shown in the examples in this thread to have
> been violated when dates and one or more durations are added.

I *think* that it's still commutative, in that:

  $dateTime + $duration = $duration + $dateTime

> We also expect consequences of these properties, such as
>     a + x = a + y   => x = y
>     x < y => x + a < y + a
> (where a is a duration and x and y are dates) to be true, and they
> are not (the converse of the first one is true, however). The
> algebra of DateTime x Duration with operation + is not the algebra
> of a group or any other familiar structure, so many of our
> expectations for the '+' operation will be violated. Typically this
> is occuring because a thing that looks like a fixed duration, such
> as P1M, is actually a different length in units of days or seconds
> depending upon the context in which it is used in addition.

Yes; I can't think of any examples where adding a dayTimeDuration to
a date or dateTime would break the normal semantics of '+', unless you
start taking leap-seconds into account (?!?)

> As you say, however, it is useful to be able to add and subtract
> dates and durations. If someone with a decent background in algebra
> can spell it out formally, there may be some way for people to use
> '+' and not have their intuition violated too often.

There's also the intuition (logic) of the machine to worry about. I
could imagine a clever XPath 2.0 processor seeing:

  a + x < a + y

and thinking that it can just do:

  x < y

in order to work out the answer.

> Otherwise, (or perhaps even if there is a formal algebra, but it's
> too exotic) treating the addition as a named function with arbitrary
> but reasonable semantics, without all the assumptions about '+' that
> we drag into every addition we see, may be the right way to proceed.

Yep, agreed. As you pointed out above, it would still be OK to use '+'
to add dayTimeDurations to dates or dateTimes, but not
yearMonthDurations (or durations more generally).



Jeni Tennison


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS