Can people show me code where they’re performing multiple IO actions in a single method chain and they think that’s *good*?
-
Show this thread
-
I just haven’t seen any code and I can’t tell if there’s some pattern I’m not aware of or if people are just using method chaining in a way I would like to discourage
1 reply 1 retweet 3 likesShow this thread -
The point of method chaining is you can decompose a complex operation into multiple small atomic operations to make it “self-explanatory.” I don’t consider IO to often be small enough that it shouldn’t be its own separate expression
2 replies 2 retweets 7 likesShow this thread -
In this vein, I think postfix syntax for await would encourage bad code patterns, unless I’m missing something
3 replies 1 retweet 7 likesShow this thread -
Replying to @withoutboats
I have wanted to say something about this on the thread but also don’t want to seem like I only complain on Lang team RFCs :/
1 reply 0 retweets 2 likes -
Replying to @steveklabnik @withoutboats
It feels like a pile on and I don’t want to encourage that. But I find it hard to see how anything postfix is compelling.
2 replies 0 retweets 3 likes -
Replying to @steveklabnik @withoutboats
While I myself lean towards prefix await, postfix makes a lot of sense as well. If you think of "?" as "get or return Err", then "await" is similarly "get or return Pending". So "await" is to "Future" like "?" is to "Result". Since "?" is postfix, perhaps "await" should be too.
1 reply 0 retweets 0 likes -
Replying to @stjepang @steveklabnik
Yea but the costs are different between await and try. The analogy is true but that doesn’t mean we should do the same thing
1 reply 0 retweets 2 likes
True, just saying there is *some* appeal to postfix await. :) FWIW, my preference is "await expr" and "await? expr". Right now I'm browsing through async/await uses on GitHub, and it seems "let foo = await!(expr)?" is like 99% of cases. Chained awaits appear to be non-existent.
-
-
Replying to @stjepang @steveklabnik
Yea I’m also inclined the same way right now. In the past I’ve favored all 3 possible prefix notations tho
1 reply 0 retweets 2 likes -
Given the magic that is await, it being a prefix or prefix keyword seems fine, as long as presidence is clear. A part of me really likes the idea of a postfix, but the magic would be a little difficult to reason about. I think you’re right about this ‘boats.
0 replies 0 retweets 2 likes
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.