Re: [XQuery] static typing of node comparisons

> I am usually in favour of static typing, but in a language like Standard
> ML, the type system is closely matched to the values and operations in
> the language, and type errors almost always reflect real errors (ie run
> time errors or incorrect results would have occurred without the static
> check).
> 
> However the existence of exactly-one() appears to be an admission that
> the type system (or at least the type inference) in use here is really a
> terrible match to the underlying data and operations and I fear that
> with the current definitions a system using the static typing as
> specified in the FS is basically unusable, the use of the static type
> system will generate far more errors than it ever detects. Requiring the
> user to have to code special functions to work round deficiencies in the
> static typing is a usability disaster.
> 
> It is probably infeasible to reliably detect whether expressions match
> node() rather than node()* as a static check as the cardinality of the
> result sequence depends on too many run time factors (eg with the
exampbe
> //book[isbn="1558604820"] here, unless isbn is of type ID you haven't
> really a hope of statically telling that this returns a single node)
> 
> In Xquery an item is the same as a sequence of one item, and it would
> probably make sense to not try to distinguish these at the static typing
> level and not try to statically distinguish any sequence based on its
> cardinality (including cardinality of one).
> 
> Obviously if node() and node()* were the same static type the
> type system is in some sense weaker, but I think in practice the result
> would be that the system was far more usable with far fewer spurious
> errors, and no requirment for fn:exactly-one() and friends.

I completely agree with David and strongly support his proposal to change
the rules for static type checking. He summarizes very precisely the
current type-checking rules and the anomalies that result from them.
Changing the type checking rules as proposed will benefit everyone.

The only remark is that instead of:

> Obviously if node() and node()* were the same static type

David probably meant:

 Obviously if node() and node()+ were the same static type

that is, to treat "exactly one" and "one or more" the same.


Dimitre Novatchev.




__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

Received on Monday, 1 December 2003 08:24:30 UTC