W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2004

RE: [F&O] 15.3 Aggregate Functions

From: Ashok Malhotra <ashokma@microsoft.com>
Date: Thu, 8 Jan 2004 10:31:12 -0800
Message-ID: <EDB607C8AC991F40BE646533A1A673E8F8D241@RED-MSG-42.redmond.corp.microsoft.com>
To: "Dimitre Novatchev" <dnovatchev@yahoo.com>, <public-qt-comments@w3.org>

Dimitre:
Thank you for your comment.  We discussed this during the joint XML
Query/XSL WG meetings on 1/8/2004.  The WGs declined to make the change
you suggested

Here is a summary of the discussion.
Three points were made.

1.  If we are using, say, fn:avg to calculate the average salary of
employees in each department then if there is a department with no
employees the it's better to return the empty sequence for this
department rather than raise an error.

2.  You can wrap the function call in fn:exactly-one to make sure that
fn:avg, for example, returns a single result.

3.  Empty sequences are pervasive in the datamodel.  It does not seem to
be a good idea to raise errors when functions are passed the empty
sequence.

Please let us know if you are satisfied with this decision.

All the best, Ashok

-----Original Message-----
From: public-qt-comments-request@w3.org
[mailto:public-qt-comments-request@w3.org] On Behalf Of Dimitre
Novatchev
Sent: Saturday, November 22, 2003 7:23 AM
To: public-qt-comments@w3.org
Subject: [F&O] 15.3 Aggregate Functions


Allowing the functions fn:max, fn:min and fn:avg to accept an empty
sequence as argument is wrong and will make using these functions
difficult and confusing.

Trying to calculate the minimum, maximum or average of an empty sequence
is an error and must be reported at the place where this error occurs.

Returning the empty sequence instead is delaying the moment at which it
is
realized that there is an error. This will lead to hidden, long-time
undiscovered errors and to difficulty in tracking the exact cause of an
error, as there has not been an immediate raising of an error as
reaction
to the exact cause.

Why should the programmer be forced to manually include additional code
to
check the type of the returned value and manually raise an error, if
this
can be done automatically by the type-checking system?


Note: These comments apply to all cases in the WD, which allow an empty
sequence argument, for which the function has no meaning. In all such
cases the type of the function must be changed to accept a non-empty
sequence.

It is necessary to analyze all cases where a fn:function is returning
the
empty sequence and to decide case by case whether having such a result
is
meaningful.

It is a benefit of typing that such errors can be caught (even sometimes
statically) and immediately reported in all cases.


Dimitre Novatchev

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
Received on Thursday, 8 January 2004 13:31:02 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:13:55 UTC