This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10724 - [XPath30] Editorial: Examples for inline function closures
Summary: [XPath30] Editorial: Examples for inline function closures
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.0 (show other bugs)
Version: Member-only Editors Drafts
Hardware: PC Windows NT
: P2 minor
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-24 15:45 UTC by Oliver Hallam
Modified: 2011-09-10 18:33 UTC (History)
1 user (show)

See Also:


Attachments

Description Oliver Hallam 2010-09-24 15:45:18 UTC
This also applies to XQuery 1.1

The last example in section 3.1.7 seeks to demonstrate that inline functions hold the values of any in-scope variables that they use:


This example creates an inline function that returns the xs:integer value 7, i.e.: the value of the variable $a from the scope of the inline function expression:
let $a := 7
return
let $f := function() { $a }
return
let $a := 8
return $f()


Firstly, The outer variable $a never has a value other than 7, so this is not a very good example.

Secondly the extra return expressions are not necessary in XQuery; they could be rewritten as ","s in XPath.

Thirdly, there is an errant ":" in the text introducing this.

Fourthly, all the examples are introduced as creating inline functions.  They in fact create function items.

Finally, this example should probably just return the function, not evaluate it



I suggest the following example instead (Much neater examples can be created in XQuery!):


This example creates a sequence of function items each of which returns a different node from the default collection.

collection()/(let $a := . return function() { $a })
Comment 1 Jonathan Robie 2011-09-10 18:33:31 UTC
Nice! I just added this to the internal Working Draft. Thanks for the great example.