<?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>8724</bug_id>
          
          <creation_ts>2010-01-12 12:06:47 +0000</creation_ts>
          <short_desc>[XQuery30] Function items need to know if they are non-deterministic</short_desc>
          <delta_ts>2011-11-01 19:20:49 +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>XQuery 3.0</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="John Snelson">john.snelson</reporter>
          <assigned_to name="John Snelson">john.snelson</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>jmdyck</cc>
    
    <cc>jonathan.robie</cc>
    
    <cc>jonathan.robie</cc>
    
    <cc>mike</cc>
          
          <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>30968</commentid>
    <comment_count>0</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-01-12 12:06:47 +0000</bug_when>
    <thetext>The signatures of function items need to record if the function is deterministic or not. Dynamic function invocation needs to use that information to restrict the optimizations performed on the function invocation.

Looking forward to XQuery Update and XQuery 1.1 support, the signatures should also contain information on whether a function is updating, sequential etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31404</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-02-02 20:47:04 +0000</bug_when>
    <thetext>Indicating determinism in the signature of the function item would make it part of the item&apos;s type, which I&apos;m not convinced is wanted. Instead, determinism could be another property of the function item (i.e., a &quot;sibling&quot; of the signature rather than part of it).

Either way, shouldn&apos;t this be raised against Data Model 1.1 (Section 2.7) rather than XQuery 1.1?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31416</commentid>
    <comment_count>2</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-02-03 11:34:48 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Indicating determinism in the signature of the function item would make it part
&gt; of the item&apos;s type, which I&apos;m not convinced is wanted.

Well I guess I was thinking that determinism is part of the information statically known about a function item. But maybe your right that this is different to the function signature.

&gt; Either way, shouldn&apos;t this be raised against Data Model 1.1 (Section 2.7)
&gt; rather than XQuery 1.1?

It&apos;s against both Data Model 1.1 and XQuery 1.1. The XQuery 1.1 part is to add rules to restrict optimization of dynamic function invocations if the function item is non-deterministic.


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31477</commentid>
    <comment_count>3</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-02-05 11:47:47 +0000</bug_when>
    <thetext>Proposal:

Data Model 1.1, 2.7 Function Items

Insert 4th bullet

* Whether the function is deterministic (either declared or determined by static analysis)

XQuery 1.1, 3.1.8 Dynamic Function Invocation

Insert 4th and 5th paragraph

A function item can be deterministic or non-deterministic. When rewriting expressions into equivalent expressions, as described in 2.3.4 Errors and Optimization, a conforming XQuery implementation must ensure that each run-time dynamic invocation of a non-deterministic function item in the original expression results in exactly one run-time invocation of the function item in the rewritten expression.

NOTE: The deterministic behaviour of a function item is a dynamic run-time property, but may be available through static analysis in some cases. Unless otherwise determined, it is most correct to assume a function item for any given dynamic function invocation will be non-deterministic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31486</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-02-05 20:04:26 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; 
&gt; * Whether the function is deterministic (either declared or determined by
&gt; static analysis)

The parenthetical is incorrect, as it implies that the property can be determined statically, which you point out is not (always) the case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31512</commentid>
    <comment_count>5</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-02-05 20:46:02 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; 
&gt; &gt; * Whether the function is deterministic (either declared or determined by
&gt; &gt; static analysis)
&gt; 
&gt; The parenthetical is incorrect, as it implies that the property can be
&gt; determined statically, which you point out is not (always) the case.

No; it can always be determined statically at the point of function item creation. It&apos;s at invocation that it can&apos;t always be accurately determined statically - but you can always guess that it&apos;s non-deterministic and get spec compliant behaviour.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31569</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-02-06 01:51:27 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; (In reply to comment #3)
&gt; &gt; &gt; 
&gt; &gt; &gt; * Whether the function is deterministic (either declared or determined by
&gt; &gt; &gt; static analysis)
&gt; &gt; 
&gt; &gt; The parenthetical is incorrect, as it implies that the property can be
&gt; &gt; determined statically, which you point out is not (always) the case.
&gt; 
&gt; No; it can always be determined statically at the point of function item
&gt; creation. It&apos;s at invocation that it can&apos;t always be accurately determined
&gt; statically

Consider a function item (A) whose function&apos;s body is basically a dynamic function invocation (DFI). Since the determinism of the function item (B) invoked by the DFI can&apos;t necessarily be determined statically, neither can the determinism of the original function item (A).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31579</commentid>
    <comment_count>7</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-02-06 02:41:30 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; No; it can always be determined statically at the point of function item
&gt; &gt; creation. It&apos;s at invocation that it can&apos;t always be accurately determined
&gt; &gt; statically
&gt; 
&gt; Consider a function item (A) whose function&apos;s body is basically a dynamic
&gt; function invocation (DFI). Since the determinism of the function item (B)
&gt; invoked by the DFI can&apos;t necessarily be determined statically, neither can the
&gt; determinism of the original function item (A).

But the determinism of a dynamic function invocation can always be statically determined - just not always accurately.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31580</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-02-06 03:26:23 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; &gt; 
&gt; &gt; Consider a function item (A) whose function&apos;s body is basically a dynamic
&gt; &gt; function invocation (DFI). Since the determinism of the function item (B)
&gt; &gt; invoked by the DFI can&apos;t necessarily be determined statically, neither can the
&gt; &gt; determinism of the original function item (A).
&gt; 
&gt; But the determinism of a dynamic function invocation can always be statically
&gt; determined - just not always accurately.

Right. And that inaccuracy propagates up to function item A. I.e., the determinism that one statically infers for A is not necessarily as precise as the actual determinism of A. I.e., you cannot always statically ascertain the determinism of a function item, which was my original point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31675</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-02-09 18:11:18 +0000</bug_when>
    <thetext>In discussion, I put forward an alternative suggestion: it should not be permitted to bind a function item to a non-deterministic function. This would mean that the compiler will always know statically when calling a dynamic function invocation that the result is deterministic. This seems important for optimization.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31848</commentid>
    <comment_count>10</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-02-12 00:51:02 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; In discussion, I put forward an alternative suggestion: it should not be
&gt; permitted to bind a function item to a non-deterministic function. This would
&gt; mean that the compiler will always know statically when calling a dynamic
&gt; function invocation that the result is deterministic. This seems important for
&gt; optimization.

Given time to reconsider, I&apos;ve got sympathy with this suggestion. I don&apos;t think that the optimization options are totally lost with the possibility of non-deterministic function items (ie: partial specialization, data flow analysis), but they are complicated and I don&apos;t see an important use case for them.

This approach would seem to require a firming up of the static analysis of determinism, so that the error conditions are well defined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32741</commentid>
    <comment_count>11</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-03-01 13:08:11 +0000</bug_when>
    <thetext>An alternative (and wider reaching) solution for this bug is proposed here:

http://lists.w3.org/Archives/Member/w3c-xsl-query/2010Feb/0204.html
http://jpcs.posterous.com/proposal-to-add-function-annotations-to-xquer</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59434</commentid>
    <comment_count>12</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2011-11-01 19:20:49 +0000</bug_when>
    <thetext>Overtaken by events.

We added the proposal in Comment #11.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>