RE: [XQuery] static typing of node comparisons

Correct. But by making the expression explicit, the user will get a
better understanding of the cost involved.

 

As I said in another mail, there is a trade-off between these two
approaches. The first will give you better performance in those cases
that your static analysis gives you enough information that you do not
have to perform the runtime check. In the second approach you will
always have to make the runtime check....

 

Best regards

Michael

 

________________________________

From: Kay, Michael [mailto:Michael.Kay@softwareag.com] 
Sent: Tuesday, December 02, 2003 3:46 AM
To: Michael Rys; Dimitre Novatchev; David Carlisle;
public-qt-comments@w3.org
Subject: RE: [XQuery] static typing of node comparisons

 

> 
> We investigated these (and some other) options in depth in 
> the WG and finally decided to be pessimistic in the first 
> version of the static typing rules to avoid the runtime checks. 
> 

But of course, you still have to do the run-time checks if the user can
only get the thing to compile by adding a call on exactly-one().

It seems to me that with optimistic typing the process is: 

1. At compile time, the system decides that there might be more than one
item, so it generates code to do a run-time check.

2. At run-time, the system checks that the sequence is a singleton. 

With pessimistic typing, the equivalent process is: 

1. At compile time, the system decides that there might be more than one
item, so it rejects the query. 
2. The user edits the query to add a call on exactly-one(). 
3. At run-time, the system evaluates the call on exactly-one() by
performing a run-time check that the sequence is a singleton.

I think I know which I prefer. 

Michael Kay 

Received on Tuesday, 2 December 2003 13:26:03 UTC