<?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>29982</bug_id>
          
          <creation_ts>2016-11-06 07:37:36 +0000</creation_ts>
          <short_desc>[XSLT30] What is this Note, comparing tunnel params with variables in functional languages referring to?</short_desc>
          <delta_ts>2016-11-17 22:24: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>XSLT 3.0</component>
          <version>Candidate Recommendation</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>minor</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>128075</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-11-06 07:37:36 +0000</bug_when>
    <thetext>We write, under the definition of Tunnel Parameters (section 10.1.3):

&quot;Tunnel parameters are conceptually similar to dynamically scoped variables in some functional programming languages.&quot;

I am not sure what this refers to. I use functional languages, though, while not claiming to be intimately familiar to all of them, I have not encountered this (unless I am confused by the terminology).

However, what *is* very common in all functional languages (except XPath) is currying:

let f a b = a + b   // function takes two arguments and adds them
let g a = f a 12    // create &quot;tunnel&quot; param for a, and fix b to 12
let h = f 42        // other way of creating &quot;tunnel&quot; param, and fix a to 42

Both functions g an f have an argument fixed, one for 12 and one for 42. The parameter a in g a is now tunneled through to f, and in h, which is seemingly without parameter, this is implicitly done.

I think that tunneled parameters in XSLT are closest to currying, even though they are distinct techniques.

Perhaps the Note in this section is supposed to mean currying with &quot;dynamically scoped variables&quot;, but I am not sure. Perhaps the safest thing is to drop it, I find it confusing..., or to be more precise about what we refer to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128081</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-06 13:19:20 +0000</bug_when>
    <thetext>I&apos;m not an expert on this area. There&apos;s a brief account of dynamic scoping in the Wikipedia article

https://en.wikipedia.org/wiki/Scope_(computer_science)#Dynamic_scoping

I think it is found in some dialects of Lisp, Scheme, Smalltalk.

The note was put there to answer the question &quot;is there any precedent or theoretical basis for the idea of tunnel parameters&quot;: it asserts that such a precedent exists, without going into great technical detail to justify this.

I would be reluctant to remove the note, since I think it points the interested reader in the right direction, and I would be reluctant to expand it, since (a) I don&apos;t have the technical background to be sure of getting it right, and (b) I don&apos;t think it&apos;s justified.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128136</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-11-10 15:53:09 +0000</bug_when>
    <thetext>I find the Wikipedia discussion fuzzy at best, but from what I read it seems indeed that there are some similarities between tunnel parameters and dynamic scoping.

However (nitpicking, sorry), it seems to be a concept irrespective of programming paradigm. You mention Smalltalk (OO language) and Wikipedia mentions Perl (multi-paradigm), Powershell (imperative, OO), Lisp (functional).

Either way, I see your point for leaving it in, let&apos;s leave it in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128146</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-11 09:46:03 +0000</bug_when>
    <thetext>The editor was asked to attempt to provide a little more context and rationale for the Note. I have redrafted it as follows:

&lt;note&gt;  
&lt;p&gt;Tunnel parameters are conceptually similar to the dynamically scoped variables found in some   functional programming languages (for example, early versions of LISP), where evaluating a   variable reference involves searching down the dynamic call stack for a matching variable   name. There are two main use cases for the feature:&lt;/p&gt;   
&lt;olist&gt;   &lt;item&gt;    &lt;p&gt;They provide a way to supply context information that might be needed by many  templates (for example, the fact that the output is to be localized for a particular  language), but which cannot be placed in a global variable because it might vary  from one phase of processing to another. Passing such information using conventional  parameters is error-prone, because a single &lt;elcode&gt;xsl:apply-templates&lt;/elcode&gt; or  &lt;elcode&gt;xsl:call-template&lt;/elcode&gt; instruction that neglects to pass the  information on will lead to failures that are difficult to diagnose.&lt;/p&gt;   &lt;/item&gt;
    &lt;item&gt;    &lt;p&gt;They are particularly useful when writing a customization layer for an existing  stylesheet. For example, if you want to override a template rule that displays  chemical formulae, you might want the new rule to be parameterized so you can apply  the house-style of a particular scientific journal. Tunnel parameters allow you to  pass this information to the overriding template rule without requiring  modifications to all the intermediate template rules. Again, a global variable could  be used, but only if the same house-style is to be used for all chemical formulae  processed during a single transformation.&lt;/p&gt;   &lt;/item&gt;  &lt;/olist&gt;   
&lt;/note&gt;

This text has been applied to the spec. Leaving the bug open for WG review.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128211</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-17 22:24:49 +0000</bug_when>
    <thetext>The WG reviewed and accepted this text (which is already in the editor&apos;s draft).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>