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 13:18:14 UTC