RE: [F&O] 15.3 Aggregate Functions

Besides the explanation that Michael Kay gave, I have to take exception
at saying that aggregators should not be defined on empty sequence.

Many set-oriented languages define them. Some define them as propagating
the absence of values (i.e. SQL propagates NULL, the empty rowset), some
define them as returning the identity value of the underlying operation.
Either of them are useful definitions. Making the case an error would be
the wrong approach.

Best regards
Michael

> -----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 Monday, 24 November 2003 13:30:13 UTC