<?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>14996</bug_id>
          
          <creation_ts>2011-11-29 15:24:50 +0000</creation_ts>
          <short_desc>[FO30] function-lookup, function-arity, function-name</short_desc>
          <delta_ts>2011-12-06 22:07:32 +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>Functions and Operators 3.0</component>
          <version>Member-only Editors Drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</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>60622</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-11-29 15:24:50 +0000</bug_when>
    <thetext>In WG meeting #491 (2011-11-15), it was decided that:

DECISION: To close bug #14330 with the following resolution:
1. function items can refer to context-independent built-in functions
2. function items can not refer to context-dependent built-in functions
3. you can create an inline function to wrap a context-dependent
built-in function

Will referencing a context-dependent built-in function raise err:XPST0112, or will a new error be created?

16.1.1 fn:function-lookup

The first example  

    fn:function-lookup(xs:QName(&apos;fn:contains&apos;), 2)(&apos;aa&apos;, &apos;a&apos;)

makes a call to function-lookup which would return a context-dependent built-in function.

This funciton will now need to raise a dynamic error (i.e. an error other than XPST0112).  Note that the function doesn&apos;t currently handle the case of focus-dependent functions.

16.1.2 fn:function-name

The first example 

    The expression fn:function-name(fn:contains#2) returns fn:QName(&quot;http://www.w3.org/2005/xpath-functions&quot;, &quot;fn:contains&quot;).

references a context-dependent built-in function.

16.1.3 fn:function-arity

The first example 

    The expression fn:function-arity(fn:contains#2) returns 2.

references a context-dependent built-in function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60637</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-11-29 18:28:41 +0000</bug_when>
    <thetext>Yes, you are right, I failed to spot that our decision on context-dependent functions invalidated these examples.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60917</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-12-04 20:48:05 +0000</bug_when>
    <thetext>I&apos;d like the following to be considered.  Rather than it being an error to reference a context or focus dependent function, instead make it an error to invoke/apply such a function reference.  This would avoid having to add an error condition for function-lookup.

It  would also mean that function-lookup, function-arity and function-name functions could operate on any function.  There may well be other functions not yet defined (e.g. Is-function-context-sensitive) which could usefully operate on all function items, and the current ruling precludes them.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60927</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-12-05 09:13:28 +0000</bug_when>
    <thetext>I guess a natural development of this idea is to make context-sensitivity a kind of function annotation, and provide methods to interrogate the annotations of a function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60928</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-12-05 09:26:45 +0000</bug_when>
    <thetext>It might also be useful to be able to mark an argument as being the context item in a user defined function, for example, to indicate that $implicit-context-item is an implicit argument of &apos;.&apos; in the following.

declare function local:foo($implicit-context-item as item(), $arg2)
{
  number($implicit-context-item) + $arg2
}

//bar/local:foo(8)

or alternatively, permit use of the context item in user defined functions

e.g.

declare function local:foo($arg2)
{
  concat(string(), $arg2)
}

//bar/local:foo(&quot; element&quot;)

causing local:foo to be annotated as being context-dependent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61056</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-12-06 22:07:32 +0000</bug_when>
    <thetext>The incorrect examples will be fixed.

The WG resolved that function-lookup applied to a context-dependent function would succeed (returning the function), but that subsequent invocation of the function would fail with a dynamic error.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>