RE: why special rule for numeric literal in a predicate?

The special rule only affects the static type inferencing, not the dynamic
semantics - I guess you knew this.

My understanding of the reasoning was that it (a) caused users too much
grief if the system failed to recognize that $seq[1] was a singleton, and
(b) would have introduced too much complexity to the static semantics to
introduce the concept of a constant sub-expression. So recognizing the
integer literal case was a compromise. 

But it's also my understanding that the formal semantics is moving in the
direction of allowing the implementor to be cleverer than this if they can.

Michael Kay

> -----Original Message-----
> From: Per Bothner [mailto:per@bothner.com] 
> Sent: 12 September 2003 18:18
> To: public-qt-comments@w3.org
> Subject: why special rule for numeric literal in a predicate?
> 
> 
> 
> I'm curious why there is a special rule for a numeric
> literal in (for example):
> 
> ForwardStep Predicates "[" Numeric "]"
> 
> By my reading, this expression:
>    STEP[2]
> is treated differently from:
>    STEP[1+1]
> or:
>    let $x as xs:integer := 2 return STEP[$x]
> or:
>    declare variable $two := {2};
>    STEP[$two]
> 
> My guess is that the translation to core XQuery
> is meant to be a purely syntactic translation,
> so it has to be done before type analysis.  Plus for the 
> re-write to be valid you would have to require that the 
> predicate be constant over the sequence, which I supposed is 
> difficult to define unless you introduce the concept of 
> "constant expression".
> 
> But given the restricted applicability of the
> simplication for just numeric literals, what's
> the point?  Is there is a specific need for a
> stricter typing of just the numeric-literal case?
> -- 
> 	--Per Bothner
> per@bothner.com   http://per.bothner.com/
> 
> 
> 

Received on Friday, 12 September 2003 14:22:21 UTC