Comments (4)
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.
@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.
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.
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)
- Explainer: Explain difference between `|>` expression and `with` statement
- Spec: Specify Feature NP (N-ary Pipelines) HOT 4
- Spec: Specify Feature BP (Block Pipelines) HOT 2
- Spec: Specify Feature TS (`try` statements)
- Readme/Spec: Drop Feature FS (`for` statements) HOT 3
- Spec, Feature PF: Specify async pipeline functions
- Feature PP (pipelines with implicit head) seems weakly motivated HOT 5
- Spec: PipelineStep must cover ConditionalExpression with supplemental production
- Spec: Cross-reference all augmented sections
- How would this interop with stateful closures? HOT 2
- Readme: Separate additional features, goals, nomenclature, term rewriting, and relations to other proposals and languages HOT 1
- Readme: Separate goals into new document HOT 1
- Spec: Remove redundant rules for chain productions
- Why was `#` chosen as the topic reference? HOT 8
- Explainer: Add example from real code using RxJS and/or Observables
- Draft a version that uses braces to distinguish pipe styles HOT 5
- Feature: Pipeline transforms HOT 2
- Full bare style option HOT 1
- [doc bug]: 'do expression' reference links refer only to ./relations.md#do-expressions && doubled 'do expression'-block HOT 1
- Exaggeration under With No Pipelines HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-smart-pipelines.