Giter VIP home page Giter VIP logo

Comments (5)

tabatkins avatar tabatkins commented on June 12, 2024 3

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.

Avaq avatar Avaq commented on June 12, 2024 1

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.

mAAdhaTTah avatar mAAdhaTTah commented on June 12, 2024

A similar idea was suggested in #276. The conversation within has some references to other conversations about it.

from proposal-pipeline-operator.

josephrocca avatar josephrocca commented on June 12, 2024

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.

tabatkins avatar tabatkins commented on June 12, 2024

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)

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.