Re: Variable references in path expressions

I also think that when a variable binds to a dynamically constructed node,
it should preserve the same node identity when it is re-evaluated.
Otherwise
    let $b := <a/> return $b is $b
would be false.

----- Original Message ----- 
From: "Bas de Bakker" <bas@x-hive.com>
To: "Michael Kay" <mhk@mhk.me.uk>
Cc: "Charles Brooking" <charles.brooking@research.canon.com.au>;
<www-ql@w3.org>
Sent: Tuesday, April 26, 2005 5:53 PM
Subject: Re: Variable references in path expressions


>
> I cannot see how the formal semantics requires this. In section 4.8.3 on
> let expressions, there is no mention of re-evaluating the expression
> bound to a variable. A let expression just extends the dynamic
> environment of the return expression with the variable bound to the
> *value* returned by the first expression. The value is then looked up
> multiple times, but this would each time return the same value with the
> same nodes (that is: nodes with the same identity).
>
> So in this case the path expression de-duplicates 3 copies of $b and
> should return (<b1/>, <b2/>, <b3/>) or an implementation dependent
> permutation of it (because the document order of new nodes is
> implementation dependent).
>
> Regards,
>
> Bas de Bakker
> X-Hive Corporation
>
>
> Michael Kay wrote:
> >> However, will
> >>
> >>     let
> >>       $a := (<a1/>, <a2/>, <a3/>),
> >>       $b := (<b1/>, <b2/>, <b3/>)
> >>     return
> >>       $a/$b
> >>
> >> return
> >>
> >>     (<b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>)
> >>
> >> because the expression bound to $b constructs unique elements
> >> each time it is evaluated?
> >
> > Yes.
> >
> >> Or should (<b1/>, <b2/>, <b3/>) be returned?
> >
> > No, this would be incorrect. (I can't point you to a discussion of this
in
> > the spec; I think the formal semantics handles the issue. But it's
certainly
> > been discussed by the WG and it's my clear understanding that the
language
> > requires this result.)
>
>

Received on Tuesday, 26 April 2005 13:46:21 UTC