Giter Club home page Giter Club logo

Comments (4)

tabatkins avatar tabatkins commented on July 30, 2024

Does this mean that PF requires NP in its entirety? Or just that it's implicitly variadic for the first pipeline, and afterwards is unary (unless NP is accepted)?

If the latter, I see how this would work with bare-form, but it seems like we would we have to accept NP's syntax additions to make it work with topic-form.

from proposal-smart-pipelines.

js-choi avatar js-choi commented on July 30, 2024

@tabatkins: Good question. No, PF does not require NP. NP is only the notation for applying N-ary arguments to expressions/functions specifically using |> with an ArgumentList (such as in (1, 2) |> f). I will clarify this in the explainer, too.

PF does not require that notation. In fact, the core proposal already defines topic bindings as a list per declarative environment record, for this very reason. During its runtime evaluation , the |> operator in the core proposal creates lists of only one element out of its head expression—but its other runtime semantics already accommodate multiple arguments even in the core proposal.

I’ve been wondering if I should update the examples in slide 17 of @littledan’s London TC39 presentation so that +> f |> g is more correctly (...$) => g(f(...$)), rather than $ => g(f($))…but there’s not much room in those slides…

from proposal-smart-pipelines.

js-choi avatar js-choi commented on July 30, 2024

Also, without Additional Feature NP, variadic parameters only apply to bare-style pipeline functions, not topic-style pipeline functions. Without Additional Feature NP, topic-style pipeline functions could use only one parameter anyway. So the fact that lexical environments already bind lists of topics doesn’t even matter. What matters is that the PipelineBodyEvaluation runtime semantic rule already does accommodate lists of topics.

I updated the examples London TC39 presentation, slide 17 in light of this issue.

from proposal-smart-pipelines.

js-choi avatar js-choi commented on July 30, 2024

Additional Feature PP (prefix |>) also needs to be tweaked to accommodate Feature PF even without Feature NP, in order to preserve both its forward compatibility with Feature NP and the invariant rule that +> |> something always cancels out into +> something. Each of the following code blocks’ lines are mutually equivalent.

// Starting with unary topic style.
+> [#] |> f |> # + 1;
($) => $ |> [#] |> f |> # + 1;
+> |> [#] |> f |> # + 1;
($) => $ |> # |> [#] |> f |> # + 1;
// Starting with unary topic style.
+> [#, ##];
($, $$) => ($, $$) |> [#, ##] |> f |> # + 1;
+> |> [#, ##];
($, $$) => ($, $$) |> (#, ##) |> [#, ##] |> f |> # + 1;
// Starting with variadic topic style (1 positional topic).
+> [#, ...];
($, ...$rest) => ($, ...$rest) |> [#, ...] |> f |> # + 1;
+> |> [#, ...];
($, ...$rest) => ($, ...$rest) |> (#, ...) |> [#, ...] |> f |> # + 1;
// Starting with variadic bare style.
+> f;
(...$rest) => ...$rest  |> f |> # + 1;
+> |> f;
(...$rest) => ...$rest |> ...  |> f |> # + 1;

In other words, even without Feature NP, prefix |> needs to use some of the same infrastructure that Feature NP uses, to determine whether the arity of a pipeline is unary or variadic. This infrastructure may be moved from Feature NP to Core Proposal, in order to distinguish +> |> f (variadic) from +> |> # + 1 (unary). From the developer’s point of view, without Feature NP, this only affects pipeline functions that start with bare-style prefix |> pipelines, like +> |> f, and nothing else.

Should be easy to do.

from proposal-smart-pipelines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.