Comments (5)
In particular, note the arguments against this in the original Smart-Mix repo, which went to great effort to identify a useful subset of unary calling that could be mixed with topic expressions in a way that was easy to identify and difficult to get wrong.
Just doing a naive "if there's a topic token, do X, otherwise do Y" ends up having bad behavior for a couple of reasons, explained in the linked README.
from proposal-pipeline-operator.
Note that in @tabatkins response, it seems they have misunderstood the proposal made by OP.
This proposes adding a separate syntax for the definition of unary lambda functions using a topic token: %.foo
defines topic => topic.foo
.
And in combination with the F# pipeline operator that would approximate the Hack proposal: x |> %.foo
-> x |> (topic => topic.foo)
-> (topic => topic.foo)(x)
-> x.foo
.
So there is no "if the topic is there, do one thing, otherwise do another" like with the Smart-Mix proposal.
However, I do see other difficulties with the proposal. For example: [%.foo, %.bar]
. Does that mean topic => [topic.foo, topic.bar]
, as it would with Hack? Or does it mean [topic => topic.foo, topic => topic.bar]
? I'm not sure if a heuristic exists by which this question can be answered reliably and in a way that doesn't surprise developers.
from proposal-pipeline-operator.
A similar idea was suggested in #276. The conversation within has some references to other conversations about it.
from proposal-pipeline-operator.
This is an interesting idea. It'd be really compelling even outside of the pipeline context if we had named function parameters and named placeholders.
let fn = %a + %b.foo();
fn(a:4, b:x)
(I wasn't able to find the discussion that tabatkins was referring to in the Smart-Mix readme.)
from proposal-pipeline-operator.
Ah, yes, I did misunderstand. Rather, this is essentially asking for Partial Function Application, just with an even wider syntax.
This is unworkable as a solution for the same reasons that F# + PFA is (it encourages the creation of a ton of one-shot functions, it doesn't work with await
, yield
, and other function-scoped abilities we add in the future, etc), but has the additional issue that the syntax is extremely ambiguous. PFA goes to some decent lengths to ensure that function-calling, by itself, is unambiguous; if you extend it to more operators it quickly runs into ambiguous situations, as you illustrated.
I'm going to go ahead and close this, then, as it's answered by #221
from proposal-pipeline-operator.
Related Issues (20)
- Combining `|>` with `=>` HOT 2
- Implementation of pipe with existing ECMAScript features HOT 2
- Wrong "F# pipes" link? HOT 3
- What if? Use `->` instead `|>` HOT 3
- Solution - Two operators? HOT 1
- Raku-style pipelining with less verbose lambda syntax HOT 1
- Proposal: create a new function instead HOT 8
- Is there a place where we can just say "please no"? HOT 5
- Simpler Syntax HOT 11
- Use @ instead of % as % is already an operator HOT 3
- Grammar rules in proposed spec text seem incomplete HOT 2
- Need to make a convincing argument why this can't be a library function HOT 2
- Combine Hack and F# Pipes HOT 4
- Make topic token optional in hack proposal in some cases HOT 6
- New motivation
- I think it would be prudent to walk away from this proposal entirely HOT 12
- Kotlin-style pipelines HOT 3
- Error Handling HOT 1
- Piping streams? 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-pipeline-operator.