RE: DN-FO-18: Empty sequence should not be allowed as argument to max(), min(), and avg()

> 
> The functions max(), min(), and avg() are defined to accept a 
> first argument of type:
> 
>       xdt:anyAtomicType*
> 
> On the other side, asking for the maximum, minimum or the 
> average of an empty sequence clearly doesn't make sense. 
> Other programming languages also require that the argument of 
> max should be a non-empty list (e.g. Haskell's prelude.hs)
> 
> The type of the first argument of these functions must be:
> 
>       xdt:anyAtomicType+
> 

We debated whether to do this, and decided that min() and max() of an empty
sequence should return () rather than being an error. This is consistent
with the general approach to handling of (), and is easier on the user given
that we have no try/catch capability to make errors non-fatal.

Michael Kay

Received on Saturday, 11 October 2003 09:55:28 UTC