[xquery-talk] SequenceType matching in For/Some/Every expressions

Jens Teubner jens.teubner at in.tum.de
Wed Sep 28 19:16:02 PDT 2005

On Wed, Sep 28, 2005 at 04:00:39PM +0200, Martin Probst wrote:

> [...]
> The only thing that adds any semantic meaning is the empty-sequence()
> statement which I would interpret as "give an error if this yields
> something". But it's really cryptic and there are better ways to do
> this.
> Am I missing something or is this an issue? The description for for/let
> clauses doesn't mention occurrences at all.

Though I agree with you that occurrence indicators are hardly sensible
in case of let/some/every, note that the semantics of the `as' clause is

 (1) test if the expression to bind is a subtype of the SequenceType
     and report an error otherwise, and
 (2) set the static type of the bound variable to the given SequenceType
     during static typing.

(see Formal Semantics, 4.8.2, second static typing rule)

Point (2) may impact the behavior if your implementation provides the
static typing feature.  In that case, a query like

  for $i as xs:integer+ in (1,2,3) return $i + 1

would yield a static type error.  $i is statically typed to xs:integer+,
which is an illegal type for the plus operator.  Of course, this is not
an argument for allowing occurrence indicators for for/some/every
clauses, but you should be aware of the twofold semantics.



Jens Teubner
Technische Universitaet Muenchen, Department of Informatics
D-85748 Garching, Germany
Tel: +49 89 289-17259     Fax: +49 89 289-17263

Young man, in mathematics you don't
understand things, you just get used to them.
                         -- John von Neumann

More information about the talk mailing list