Comments (7)
So, I don't fully understand what you mean.
from babel-plugin-transform-pipeline.
For example, if I have
let log = [];
function f() { log.push("f") }
function g() { log.push("g") }
f() |> g()
After that code runs, log
should be ["f", "g"]
.
I don't see examples in the proposal, probably because it doesn't really make sense to write code this way.
from babel-plugin-transform-pipeline.
Yeah, that's right. These ways are equivalent:
Calling in calling:
let log = [];
function f() { log.push("f") }
function g() { log.push("g") }
f() |> g
console.log(log) // => ["f", "g"]
Pipeline:
let log = [];
function f() { log.push("f") }
function g() { log.push("g") }
g(f())
console.log(log) // => ["f", "g"]
And, as I understand it, when we use a pipeline, we say:
f() // Get result of this function
|> // and put it as a first parameter in to
g // that function, and call it.
Or did I misunderstand you?
from babel-plugin-transform-pipeline.
Sorry, there was a typo in my example, and it seems like you fixed it in a direction that's different from what I was going for. It should be:
function g() { log.push("g"); return () => {} }
Then, the code f() |> g()
is related to the code g()(f())
.
But! They differ in the evaluation order of f()
vs g()
. In the pipeline example, f()
runs first. But in the normal function call code, g()
goes first.
This can be fixed by desugaring into something like this:
let __arg = f();
let __fn = g();
__fn(__arg)
from babel-plugin-transform-pipeline.
Oh, I understood what you mean, but I didn't find an opinion on this case in proposal.
I think, you'd better ask this question in proposal repo: https://github.com/tc39/proposal-pipeline-operator
Please let me know later what they think about this.
Or my implementation is wrong?
from babel-plugin-transform-pipeline.
Well, that proposal doesn't have specific enough spec text to say things one way or another.
I'd be really surprised if it went any other way than left-to-right (and I think it would be shot down in committee if so), but it would be fine with me if you feel like waiting for more solid confirmation first.
from babel-plugin-transform-pipeline.
I made a spec text proposal at tc39/proposal-pipeline-operator#51 which evaluates the left argument before the right one. I'd be interested in any feedback you have.
from babel-plugin-transform-pipeline.
Related Issues (6)
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 babel-plugin-transform-pipeline.