<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26439</bug_id>
          
          <creation_ts>2014-07-27 23:23:52 +0000</creation_ts>
          <short_desc>[XSLT30] fn:fold-left in streamability rules can take type-determined usage into account (from note in test)</short_desc>
          <delta_ts>2014-09-05 11:55:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Abel Braaksma">abel.braaksma</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>109331</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-07-27 23:23:52 +0000</bug_when>
    <thetext>In test sf-fold-left-003 in test-set sf-fold-left (see top of this file: https://dvcs.w3.org/hg/xslt30-test/file/ed6d3af522b5/tests/strm/sf-fold-left/sf-fold-left-A.xsl) there&apos;s a comment with a &quot;TODO&quot;, implying that TDU can be used with fold-left. I think this is correct. The full comment says it all:


&gt; TODO: fold-left is defined in the current XSLT 3.0 draft to 
&gt; have the operand usage N (Navigation) making it non-streamable. 
&gt; This should be fixed; it should have type-determined usage 
&gt; based on the type of the first argument of the function 
&gt; provided in the third argument, if this is known. In the 
&gt; meantime, we explicitly atomize the sequence to be processed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109584</commentid>
    <comment_count>1</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2014-07-30 15:45:25 +0000</bug_when>
    <thetext>We considered this at F2F meeting in Hursley 30 July 2014 and concluded that the original bug description is a desirable change. Michael Kay has been given an action item to come up with a proposal.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109750</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-08-01 11:14:16 +0000</bug_when>
    <thetext>Proposal:

fold-left() should use the GSR, with the operand usage of the first argument being the type-determined usage based on the type of the second argument of the supplied function.

Consider:

fold-left($seq, 0, declare function ($n as numeric, $m as numeric) as numeric {$n+$m})

where $seq is striding and consuming.

The TDU of $m is absorption, therefore the OU of $seq is absorption, therefore fold-left is grounded and consuming. 

How do we know it&apos;s grounded? Because both $zero and $fn are grounded...

We think there&apos;s potential for going beyond this e.g when using streamable stylesheet functions or known built-in functions but it gets tricky.

Still needs further work to flesh out the detail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109751</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-08-01 11:22:32 +0000</bug_when>
    <thetext>Note also that whatever we do for fold-left, we can probably also do the same or similar for filter and for-each, perhaps also for-each-pair.

For filter: it should behave like filter expressions if we know the supplied function is motionless (or has operand usage inspection). We can only know this for built-in functions (or inline functions if we choose to analyse them), for example it should be possible to make the following work:

filter(/*/x, function($n) {lang(&apos;en&apos;, $n)})

filter(/*/x, lang(&apos;en&apos;, ?))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110420</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-08-21 17:14:35 +0000</bug_when>
    <thetext>Briefly discussed during today&apos;s telcon, though it is awaiting completion of an action to produce a proposal. The question was raised as to what kind of function items would be allowed in the third argument. Only allowing built-in functions would be rather restrictive. Allowing functions that atomize their arguments should be OK (but perhaps we already allow that?). To be at all useful, we need to allow user-defined functions (e.g. inline functions) and it&apos;s not clear how we can constrain them suitably.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111036</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-09-04 21:18:58 +0000</bug_when>
    <thetext>The WG accepted the proposal in

https://lists.w3.org/Archives/Member/w3c-xsl-wg/2014Sep/0002.html

(member-only)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111059</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-09-05 11:43:00 +0000</bug_when>
    <thetext>For fn:filter, the rules don&apos;t quite work in the same way. By analogy with filter expressions, filter($seq, $f) has the posture and sweep of $f provided that a call on $f is motionless. We can be sure that a dynamic call on $f is motionless only if:

(a) $seq is grounded, or

(b) $f is a known built-in function such as fn:nilled#1 where the argument has inspection usage, or 

(c) $f is an inline function whose body we are prepared to analyse.

But (b) covers so few useful cases that it really isn&apos;t worth bothering, especially as these cases can always be expressed by a simple filter expression: emp[nilled()]; and (c) is going into new territory that is best left untouched for now.

Given that case (a) is already handled, I&apos;m going to make no change for fn:filter.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111060</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-09-05 11:55:59 +0000</bug_when>
    <thetext>The agreed changes have been applied, affecting fn:fold-left, fn:for-each, and fn:for-each-pair.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>