{"action":"created","issue":{"url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/4","labels_url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/4/comments","events_url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/4/events","html_url":"https://github.com/mindeavor/es-pipeline-operator/issues/4","id":120655335,"number":4,"title":"Alternate syntax","user":{"login":"mindeavor","id":17013,"avatar_url":"https://avatars.githubusercontent.com/u/17013?v=3","gravatar_id":"","url":"https://api.github.com/users/mindeavor","html_url":"https://github.com/mindeavor","followers_url":"https://api.github.com/users/mindeavor/followers","following_url":"https://api.github.com/users/mindeavor/following{/other_user}","gists_url":"https://api.github.com/users/mindeavor/gists{/gist_id}","starred_url":"https://api.github.com/users/mindeavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindeavor/subscriptions","organizations_url":"https://api.github.com/users/mindeavor/orgs","repos_url":"https://api.github.com/users/mindeavor/repos","events_url":"https://api.github.com/users/mindeavor/events{/privacy}","received_events_url":"https://api.github.com/users/mindeavor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-06T19:53:25Z","updated_at":"2015-12-06T20:54:04Z","closed_at":null,"body":"Although I wrote the proposal, I do recognize a potential objection: [functions with multiple arguments](https://github.com/mindeavor/es-pipeline-operator#functions-with-multiple-arguments).\r\n\r\nAlthough to me using arrow functions is perfectly explicit and clear, for the sake of argument let's explore two possible alternatives to handling this situation.\r\n\r\n## 1. Elixir-style Inlining\r\n\r\nElixir's pipeline operator is actually different than the original proposal you see in this repo (of which we will call **F# style**). Instead of simply calling the right-hand side with the left-hand side, it instead **inserts** the left-hand side as the first argument to the right:\r\n\r\n```js\r\n// F# style\r\nrun(\"hello\") |> withThis(10);\r\n// is equivalent to\r\nwithThis(10)( run(\"hello\") );\r\n\r\n// Elixir style\r\nrun(\"hello\") |> withThis(10);\r\n// is equivalent to\r\nwithThis( run(\"hello\"), 10 );\r\n\r\n//\r\n// More complicated example\r\n//\r\n// F# style\r\nrun(\"hello\") |> withThis(10) |> andThis(20);\r\n// is equivalent to\r\nandThis(20)( withThis(10)( run(\"hello\") ) );\r\n\r\n// Elixir style\r\nrun(\"hello\") |> withThis(10) |> andThis(20);\r\n// is equivalent to\r\nandThis( withThis( run(\"hello\"), 10 ), 20 );\r\n```\r\n\r\n### Pros / Cons\r\n\r\n- :+1: Less function calls (2 vs 3)\r\n- :+1: Compatible with much more of the JavaScript ecosystem\r\n- :-1: Gives a new semantic meaning to what looks like a normal function call. For example, `withThis(10)` is no longer just calling that function with one argument\r\n- :-1: Putting the left-hand side as the first argument to the right-hand side is pretty arbitrary.\r\n\r\n## 2. Placeholder Arguments\r\n\r\nAnother alternative is to have a new syntax for \"placeholder arguments\" – basically, slots waiting to be filled by the next function call. For example:\r\n\r\n```js\r\n// Placeholder style\r\nrun(\"hello\") |> withThis(10, #);\r\n// is equivalent to\r\nwithThis( 10, run(\"hello\") );\r\n\r\n//\r\n// More complicated example\r\n//\r\nrun(\"hello\") |> withThis(10, #) |> andThis(#, 20);\r\n// is equivalent to\r\nandThis( withThis( 10, run(\"hello\") ), 20 );\r\n```\r\n\r\n### Pros / Cons\r\n\r\n- :+1: Very explicit (no surprises)\r\n- :+1: Less function calls\r\n- :+1: Compatible with even more of the JavaScript ecosystem\r\n- :-1: Requires more new syntax\r\n- :-1: Usage of the hash operator (#) would probably be hard to define outside coupled use with pipeline operator (this problem could be avoided by simply making it illegal)\r\n\r\nAny thoughts and feedback would be greatly appreciated. Even if you are reiterating some of the points I've made, it's important to express them so we can see what the community thinks. Thanks for reading."},"comment":{"url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/comments/162346639","html_url":"https://github.com/mindeavor/es-pipeline-operator/issues/4#issuecomment-162346639","issue_url":"https://api.github.com/repos/mindeavor/es-pipeline-operator/issues/4","id":162346639,"user":{"login":"mindeavor","id":17013,"avatar_url":"https://avatars.githubusercontent.com/u/17013?v=3","gravatar_id":"","url":"https://api.github.com/users/mindeavor","html_url":"https://github.com/mindeavor","followers_url":"https://api.github.com/users/mindeavor/followers","following_url":"https://api.github.com/users/mindeavor/following{/other_user}","gists_url":"https://api.github.com/users/mindeavor/gists{/gist_id}","starred_url":"https://api.github.com/users/mindeavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindeavor/subscriptions","organizations_url":"https://api.github.com/users/mindeavor/orgs","repos_url":"https://api.github.com/users/mindeavor/repos","events_url":"https://api.github.com/users/mindeavor/events{/privacy}","received_events_url":"https://api.github.com/users/mindeavor/received_events","type":"User","site_admin":false},"created_at":"2015-12-06T20:54:04Z","updated_at":"2015-12-06T20:54:04Z","body":"@eplawless Great points, this is something that would need to be worked out (assuming people are really against just using arrow functions).\r\n\r\n@seanstrom @AriaMinaei Thank you for the links to LiveScript's prior art, it's good to know that others already find the `|>` operator useful. I would also love to have underscore as partial application, but as you and I know, underscore is a commonly used variable name in JS :)"}}