W3C home > Mailing lists > Public > public-qt-comments@w3.org > October 2007

RE: Better static type checking for XQuery

From: Michael Kay <mike@saxonica.com>
Date: Wed, 17 Oct 2007 19:37:55 +0100
To: "'Bill Patton'" <bpatton_temp8345@cogneticsystems.com>, <public-qt-comments@w3.org>
Message-ID: <013c01c810ec$d542f300$6501a8c0@turtle>

> In addition to using more accurate type checking rules, it 
> may be possible to make XQuery static type checking more 
> user-friendly by relaxing some of the rules.
> Does anyone know of any useful relaxations for static type 
> checking rules which would produce fewer type errors without 
> unduly sacrificing type safety?

XQuery implementations are not obliged to implement static type checking (or
"pessimistic" static checking as I call it). And in fact, I think most
implementations don't.

Saxon implements what I call "optimistic" static type checking. At compile
time it compares the static type of the supplied value (S) to the required
type (R). If R subsumes S, all is well. If R and S are disjoint, you get a
static error. If R and S overlap, code is generated to do a dynamic type
check. There is also one special rule: if the intersection of R and S is the
empty sequence, you get a compile-time warning (this covers the case where
the supplied type is string? and the required type is integer?).

Personally I think this gives you much better usability.

The rules in the spec allow pretty well any combination of static and
dynamic type checking.

Michael Kay
(personal response) 
Received on Wednesday, 17 October 2007 18:38:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:20 UTC