<p dir="ltr">Not with your semantics. It has to generate a closure each time, because of the possibility it can't be used elsewhere. That's impossible to know ahead of time if the variable is ever used outside of its closure or as a value. In the case below, it should only log thrice. Otherwise, it's unexpected behavior. </p>
<p dir="ltr">```js<br>
function add(x) {<br>
  console.log("Hit!");<br>
  return y => x + y;<br>
}</p>
<p dir="ltr">let inc = add(1);</p>
<p dir="ltr">1 |> inc |> inc |> add(2) |> add(3);</p>
<p dir="ltr">// Hit!<br>
// Hit!<br>
// Hit!<br>
```</p>
<p dir="ltr"></p>
<p dir="ltr">On Tue, Nov 10, 2015, 15:08 Gilbert B Garza <<a href="mailto:gilbertbgarza@gmail.com">gilbertbgarza@gmail.com</a>> wrote:</p>
<blockquote><blockquote><blockquote><p dir="ltr">Normally yes, but since the pipeline operator is a pure function, I think it's possible for the compiler to optimize away the intermediate arrow functions. I mention this in the "Functions with Multiple Arguments" section <a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">https</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">://</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">github.com</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">/</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">mindeavor</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">/</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">ES7-pipeline-operator#functions</a><a href="https://github.com/mindeavor/ES7-pipeline-operator#functions-with-multiple-arguments">-with-multiple-arguments</a><br>
</p>
</blockquote>
</blockquote>
</blockquote>
<blockquote><blockquote><p dir="ltr"><br></p>
<p dir="ltr">On Tue, Nov 10, 2015 at 12:52 PM, Isiah Meadows <<a href="mailto:isiahmeadows@gmail.com">isiahmeadows@gmail.com</a>> wrote:</p>
</blockquote>
</blockquote>
<blockquote><blockquote><p dir="ltr">Inline</p>
<p dir="ltr">On Tue, Nov 10, 2015 at 12:52 PM, Kevin Smith <<a href="mailto:zenparsing@gmail.com">zenparsing@gmail.com</a>> wrote:<br>
>> - I don't like the requirement to use the keyword `this` to compose<br>
>> functions. JS already has many features to support the keyword `this`:<br>
>> prototypes, method invocations, function binding, arrow functions, and<br>
>> probably others. I prefer a feature that assists the other side of the<br>
>> spectrum.<br>
><br>
><br>
> Yep - a well documented critique.  It depends on your point of view, I<br>
> think.  If you view these things as "extension methods", then using `this`<br>
> makes more sense.<br>
><br>
>> - The fact that there are new semantics to what looks like a normal<br>
>> function call (e.g. `->map(...)`) doesn't set well with me. You could argue<br>
>> that it's something to get used to. Even in that case, I would expect the<br>
>> first argument I give to `map` to stay the first argument.<br>
><br>
><br>
> This is a reasonable objection, I think.</p>
<p dir="ltr">Not to mention it's still a point of contention:<br>
<a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">https</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">://</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">github.com</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">/</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">zenparsing</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">/</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">es-function-bind</a><a href="https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154130932">/issues/26#issuecomment-154130932</a><br>
(from here, down)</p>
<p dir="ltr">><br>
>> With the pipeline operator, partial application is left to the developer.<br>
>> They can choose to use arrow functions, or to curry their functions. I think<br>
>> this is the best option since it keeps things simple (no new semantics), and<br>
>> remains readable – see the "Function with Multiple Arguments" section in the<br>
>> GitHub link <a href="https://github.com/mindeavor/ES7-pipeline-operator">https</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">://</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">github.com</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">/</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">mindeavor</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">/</a><a href="https://github.com/mindeavor/ES7-pipeline-operator">ES7-pipeline-operator</a><br>
><br>
><br>
> I agree that your proposal wins points for simplicity (both semantic and<br>
> syntactic), but having to create an arrow function to pass more than one<br>
> argument feels a bit awkward and seems to defeat some of the readability<br>
> benefit.</p>
<p dir="ltr">Not to mention it would be pretty slow. That's going to be creating a<br>
closure each call. Engines still struggle with making closures fast.<br>
It's non-trivial at runtime to create a closure that's performant.<br></p>
<p dir="ltr">><br>
><br>
><br>
> _______________________________________________<br>
> es-discuss mailing list<br>
> <a href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
> <a href="https://mail.mozilla.org/listinfo/es-discuss">https</a><a href="https://mail.mozilla.org/listinfo/es-discuss">://</a><a href="https://mail.mozilla.org/listinfo/es-discuss">mail.mozilla.org</a><a href="https://mail.mozilla.org/listinfo/es-discuss">/</a><a href="https://mail.mozilla.org/listinfo/es-discuss">listinfo</a><a href="https://mail.mozilla.org/listinfo/es-discuss">/</a><a href="https://mail.mozilla.org/listinfo/es-discuss">es-discuss</a><br>
><br><br></p>
<p dir="ltr"><font color="#888888">--</font><br>
<font color="#888888">Isiah Meadows</font><br>
</p>
</blockquote>
</blockquote>
<blockquote><p dir="ltr"><br>
</p>
</blockquote>
<p dir="ltr"><br>
</p>