[xquery-talk] a conceptual clarification

Michael Rys mrys at microsoft.com
Wed Mar 2 22:01:20 PST 2005


The statements are all legal according to the spec (although in our
implementation we currently error since we don't trust the spec yet in
this regard not to change). 

The latest $x is taken. So foo returns 2 and bar returns 4.

Best regards
Michael

> -----Original Message-----
> From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On
Behalf
> Of Ronald Bourret
> Sent: Wednesday, March 02, 2005 9:05 PM
> To: talk at xquery.com
> Subject: Re: [xquery-talk] a conceptual clarification
> 
> Per Bothner wrote:
> 
> >> question here is,  whether Query No. 2 is violative of the rule
stated
> >> in para 1 above.
> >
> > There is no difference bewteen query 1 and query 2.
> 
> The following is from query 2:
> 
>    declare function my:square ($x)
>    {
>      let $x := $x * $x
>      return $x
>    };
> 
> Just to be clear, this is legal because the $x in the parameter
> declaration is in a different namespace / symbol space / whatever you
> call it that the $x in the let statement? But even if this is true,
how
> does one decide which $x is returned by the return statement?
> 
> Based on this, are the following functions legal or illegal?
> 
>     declare function foo()
>     {
>        let $x := 1
>        let $x := 2
>        return $x
>     }
> 
>     declare function bar()
>     {
>        let $x := 2
>        let $x := $x * $x
>        return $x
>     }
> 
> I must admit to some confusion here...
> 
> -- Ron
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk



More information about the talk mailing list