Giter VIP home page Giter VIP logo

Comments (5)

Coneko avatar Coneko commented on April 19, 2024

I don't think a traditional do syntax would be very useful in objc.

If all you're doing is chaining bind:s, the syntax would be just a bit lighter, but the general readability would suffer because of it's inconsistency with the rest of the code.
If you're composing bind:s, objc already allows you to assign the result of bind:s to variables, so there's no need for a <- operator.

What really hurts readability as it is now, is splitting and merging streams through publish and combineLatest:, or working with a lot of tuples to avoid doing that. Especially since objc's type signatures don't allow you to specify what is in the tuples.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 19, 2024

If you're composing bind:s, objc already allows you to assign the result of bind:s to variables, so there's no need for a <- operator.

This is a little bit of a red herring, because:

do
    x <- M
    

maps to something like the following Objective-C:

[M bind:^(id x) {
    …
}];

That said, I agree with your overall point. I don't think do syntax would be that useful for how RAC is generally going to be used.

from reactivecocoa.

joshaber avatar joshaber commented on April 19, 2024

I think the value of do syntax is that deeply nested binds are gross.

So, compare:

do 
    x <- f1
    y <- f2 x
    z <- f3 x y
    return x + y + z

vs.

[[self f1] bind:^(id x) {
    return [[self f2:x] bind:^(id y) {
        return [[self f3:x and:y] bind:^(id z) {
            return [self.class return:[[x plus:y] plus:z]];
        }];
    }];
}];

Nesting aspolsion.

The question in my mind is whether a macro could be better enough to make it worthwhile.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 19, 2024

A do macro would end up fairly similar to Clojure's:

do(
    x, [self f1],
    y, [self f2],
    z, [self f3:x and:y],
    [self.class return:[[x plus:y] plus:z]]
)

I just don't think people will be binding that often/intensely.

from reactivecocoa.

joshaber avatar joshaber commented on April 19, 2024

Yeah, I agree. Not much better and probably rare.

from reactivecocoa.

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.