[Bug 10724] New: [XPath 21] Editorial: Examples for inline function closures

http://www.w3.org/Bugs/Public/show_bug.cgi?id=10724

           Summary: [XPath 21] Editorial: Examples for inline function
                    closures
           Product: XPath / XQuery / XSLT
           Version: Member-only Editors Drafts
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath 2.1
        AssignedTo: jonathan.robie@redhat.com
        ReportedBy: oliver@cbcl.co.uk
         QAContact: public-qt-comments@w3.org


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 })

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Friday, 24 September 2010 15:45:20 UTC