A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tc39/proposal-pipeline-operator/issues/75 below:

Pipeline Placeholders · Issue #75 · tc39/proposal-pipeline-operator · GitHub

I'd like to explore an alternative to the partial application proposal that would only be used in conjunction with the pipeline operator.

There has been discussion around using ? as a placeholder for functions with multiple arguments. Consider the readme example:

let person = { score: 25 };

let newScore = person.score
  |> double
  |> (_ => add(7, _))
  |> (_ => boundScore(0, 100, _));

newScore //=> 57

If the ? were to be built into the pipeline operator, we could rewrite the example to the following:

let newScore = person.score
  |> double
  |> add(7, ?)
  |> boundScore(0, 100, ?);

and since this placeholder is scoped to the pipeline operator, it has the potential to be more expressive:

let ex1 = person |> double(?.score);
let ex2 = person.score |> add(?, ?);

and potentially allow member expressions?

let x = 10 |> f |> ?.foo |> g;

On the other hand, any sort of ? placeholder might have people let write strange things like
x |> f(? ? ? : 10). Is this problematic?

davegregg, trustedtomato, jamen, kube, rauschma and 2 morecharmander


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4