[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: limits of the generic


Re:  limits of the generic
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).

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.