<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0.8em 0px!important">On Mon, Jul 6, 2015 at 10:09 AM, Michael Kay <<a href="mailto:mike@saxonica.com" target="_blank">mike@saxonica.com</a>> wrote:</p>
<p style="margin:0.8em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Adding capability to XQuery 3.1 at this stage will require a more convincing justification than “I felt the need for this in some edge cases”.</blockquote><p></p></div><p style="margin:0.8em 0px!important"></p>
<p style="margin:0.8em 0px!important">On Mon, Jul 6, 2015 at 10:40 AM, Christian Grün <a href="http://mailto:[christian.gruen@gmail.com](mailto:christian.gruen@gmail.com)">[christian.gruen@gmail.com](mailto:christian.gruen@gmail.com)</a> wrote:</p>
<p style="margin:0.8em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="overflow:hidden">The function call might disappear in the evaluated code, and the<br>resulting expression "123 + 456" might include no reference to the<br>original function anymore.</div></blockquote><p></p></div><p style="margin:0.8em 0px!important"></p>
<p style="margin:0.8em 0px!important">Thanks Michael and Christian,</p>
<p style="margin:0.8em 0px!important">Understood and agreed. I was not aware that 3.1 was so close from final and did not mean to be insistent. So far, I am not aware of other Functional languages proposing this type of feature, so consider this request as closed ; ) </p>
<p style="margin:0.8em 0px!important">Best,<br>Christophe</p>
<p style="margin:0.8em 0px!important">P.S.<br>Just to elaborate on one example “edge case”, this the type of pattern I use for some restxq resource functions (Adam’s Retter eXist implementation). It has the advantages of attaching higher level success and error messages as metaData to resource functions. Having a function-item() function returning the current function being executed would avoid re-typing the function item <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">local:myResourceFunction#arity</code> when the signature of the function changes - not much more convincing as a justification !</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,255)">declare 
  %rest: ... restxq annotation for the function
  %msg:success('successKey', 'successMessage'), 
  %msg:error('errorKey', 'errorMessage'), 

  function local:myResourceFunction($args) {
      let $fn:= function() { 
        let $initialCheck := loginAttemptAndOtherChecks($args) (: throw an exception if not succesfull:)
        let $doTheWork:= local:doTheWork($args) 
      }
      return local:processResoureFunction($fn, local:myResourceFunction#arity)
 };

declare function local:processResourceFunction($fn, $callee ) {
    try { 
      $fn(),
      local:retrieveSuccessMessage($callee)

   } catch * {
      local:retrieveErrorMessage($callee, $err:code, $err:description, $err:value)
  } 
};

declare function local:doTheWork() {
   (: do the work here, throw exceptions on errors:)
};
</code></pre><div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxicj48ZGl2IGNsYXNzPSJnbWFpbF9xdW90ZSI+T24g
TW9uLCBKdWwgNiwgMjAxNSBhdCAxMDowOSBBTSwgTWljaGFlbCBLYXkgPHNwYW4gZGlyPSJsdHIi
PiZsdDs8YSBocmVmPSJtYWlsdG86bWlrZUBzYXhvbmljYS5jb20iIHRhcmdldD0iX2JsYW5rIj5t
aWtlQHNheG9uaWNhLmNvbTwvYT4mZ3Q7PC9zcGFuPiB3cm90ZTo8YnI+PGJsb2NrcXVvdGUgY2xh
c3M9ImdtYWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOiAwcHggMHB4IDB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