[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

static typing of XQuery?

Michael Kay mhk at mhk.me.uk
Wed Sep 20 23:30:38 PDT 2006


  static typing of XQuery?
> Does Saxon implement full "optimistic static typing" or just 
> some ad-hoc subset?  By the former I mean the type system of 
> the FS but, but with more lenience ("optimism")?  If so, it 
> seems that implementing full static type checking should not 
> be difficult.

My inference rules are sometimes weaker than those in FS, sometimes
stronger.

Examples of weaker rules: I only analyze the child and attribute axes; I
don't infer union types (instead using the lowest common supertype).

Examples of stronger rules: variables and functions have a type inferred
from their expression body if no type is declared; constant subexpressions
take their actual (dynamic) type.

The "optimism" doesn't relate to the inference rules themselves, but to what
is treated as an error. If the static type is disjoint from the required
type I report a compile-time error; if they overlap then I generate run-time
type-checking code. As a special case, if the only value in the intersection
of the static type and the required type is the empty sequence, I report a
compile time warning (for example, when the static type is string? and the
required type is integer?). 
> 
> My feeling (which seems to match yours) is that optimistic 
> static typing is useful and should perhaps be the default 
> (pending further experience), but pessimistic/strict typing 
> would be nice to have as an option for those who want it, but 
> should not be the default.

I'll await practical experience before deciding that pessimistic static
typing is ever beneficial.

Michael Kay
http://www.saxonica.com/



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.