[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 Saturday, 22 November 2003 10:23:32 UTC