<?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>9787</bug_id>
          
          <creation_ts>2010-05-21 11:05:02 +0000</creation_ts>
          <short_desc>[XQ31ReqUC] Default values for function arguments</short_desc>
          <delta_ts>2014-05-20 16:54:08 +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>Requirements for Future Versions</component>
          <version>Working drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></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>
          <dependson>9062</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="nunojob">nunojobpinto</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>john.snelson</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>35791</commentid>
    <comment_count>0</comment_count>
    <who name="nunojob">nunojobpinto</who>
    <bug_when>2010-05-21 11:05:02 +0000</bug_when>
    <thetext>define function local:foo($bar, $baz=fn:current-date-time()) { ... } ;

instead of

define function local:foo($bar) { local:foo($bar, 
fn:current-date-time())  } ;
define function local:foo($bar, $baz) { ... } ;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35792</commentid>
    <comment_count>1</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2010-05-21 13:17:21 +0000</bug_when>
    <thetext>I think this is an interesting future direction, since it will also allow users to safely define functions that take the context item as an implicit argument:

define function local:findIDs($node as node() := .)
{
  $node//@id
};

This kind of default argument is evaluated in the calling context, rather than the function&apos;s context.

That said, this is almost certainly a feature that should be considered for XQuery 1.2 rather than XQuery 1.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35947</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-06-03 19:53:07 +0000</bug_when>
    <thetext>Polymorphism is already listed as a potential feature for future versions, as are generics:

Bug 9062

This is related to polymorphism, but you ask for defaults as well. I&apos;d like to move this to future versions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71449</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-07-25 14:26:29 +0000</bug_when>
    <thetext>Renamed the requirement to emphasize its relatively modest ambitions; as described, this is simply a convenient way of defining a family of functions with the same name and different arity using fewer lines of code than currently needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71450</commentid>
    <comment_count>4</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2012-07-25 14:52:11 +0000</bug_when>
    <thetext>There&apos;s a little more to this feature request. Default arguments would be evaluated in the static and dynamic context of the caller, which would allow the definition of functions which took a default context item, for instance.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71468</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-07-25 21:28:14 +0000</bug_when>
    <thetext>The static environment of the caller? So $x:var accesses different variables depending on the namespace binding of x? Surely not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71504</commentid>
    <comment_count>6</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2012-07-26 10:55:38 +0000</bug_when>
    <thetext>Interesting point - this clearly needs more thought.

I do think it&apos;s reasonable to have a default argument of fn:default-collation() however, which is what I was thinking of when I said it should use the static context of the caller.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106476</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-05-20 16:54:08 +0000</bug_when>
    <thetext>Assigning to future requirements per Working Group decision (https://lists.w3.org/Archives/Member/w3c-xsl-query/2012Oct/0087.html).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>