input |> func(?, 2)
input |> func(1, ?)
While hack's placeholders work exclusively in pipelines, the partial application proposal can be used with any function "123"
.split("")
.map(parseInt(?)) // make sure radix param is not set
[1] https://github.com/tc39/proposal-partial-application (as-> [:foo :bar] v
(map name v)
(first v)
(.substring v 1)) y %>% f(x, ., z) === f(x, y, z)
R lets you do macro-ish things at at runtime [1], and `.` is a valid variable name [2]. so %>% can just evaluate the AST of its right argument in an environment with `. = a`.(it's probably a bit more involved because %>% also supports
a %>% f(b) === f(a, b)
in which case %>% has to do some AST surgery to splice another argument in front of `b`.)---
[1] https://en.wikipedia.org/wiki/Fexpr
[2] think `_` in python etc. R uses dots instead of underscores
Actualy this whole debate should be called scala vs F# because they are more corresponding, being both functional language on a OOP runtime.
For most of these proposals it is just syntactic sugar around invoking the function with a placeholder. The pipe in F# is slightly different in that most of the time it has no intermediate lambdas and is compiled in a more performant form. The downside is that unless you allocate that lambda yourself it has to be the last arg. On the plus side like most things in F# it is concise but shows all behavior explicitly - its usually a warning sign if you have to do that and helps reason about performance. Sometimes its a sign that the original function isn't written right or some other inline wrapper could be used for other usages of the function. You can inline a template to rearrange the arg's (inline) to avoid the lambda allocation as well.
This allows some level of re-use and performance benefits avoiding virtual table dispatch and a lambda allocation for many common methods (e.g. map, fold, iter, etc)
I believe the point made in the discussion is that the F# proposal leads to intermediate lambda if the function does not have the right arity. JS also don't do HM so that point is moot.
The people supporting the Hack proposal made the point that their expressions do not desugar to lambda and has no runtime cost, no idea how it works though.