3 ms·
The current JS argument order is a mess too because you'd ideally want your collection last so you can partially apply the parts you'd normally apply and compos
by toastal 5y ago
The current JS argument order is a mess too because you'd ideally want your collection last so you can partially apply the parts you'd normally apply and compose transformations for that collection, but most function arguments aren't in this order. Elixir is the 'weird' language piping the first argument instead of the last, so I guess that is a solution, but it doesn't fit the 'normal' compositional style from ML-family languages. This might be a requirement for languages with variadic functions.
The spec points to the `%` placeholder-y thing from Hack which shows how weird piping gets in an uncurried language like JavaScript. I think these issues illustrate how nontrivial adding piping would actually be in JavaScript.
Currying is the obvious, simplest solution because it's always one parameter in and only one thing is returned (often a function awaiting one new argument). But this would require massive fundamental changes to the builtins probably requiring something like "use currying" to tell the user agent to flip the argument order and curry all the functions. I'd be pretty into this though.
- guerrilla 5y ago> But this would require massive fundamental changes to the builtins probably requiring something like "use currying" to tell the user agent to flip the argument order and curry all the functions. I'd be pretty into this though. Could you just clone them and expose versions with swapped arguments under a different namespace?