←back to thread

292 points kristoff_it | 5 comments | | HN request time: 0.945s | source
Show context
raluk ◴[] No.44609651[source]
One thing that most languages are lacking is expressing lazy return values. -> await f1() + await f2() and to express this concurently requres manually handing of futures.
replies(3): >>44609880 #>>44610056 #>>44610348 #
sedatk ◴[] No.44609880[source]
Which languages do have such a thing?
replies(2): >>44610179 #>>44610709 #
steveklabnik ◴[] No.44610709[source]
Rust does this, if you don’t call await on them. You can then await on the join of both.
replies(1): >>44610738 #
1. sedatk ◴[] No.44610738[source]
Is the "join" syntax part of the language?
replies(2): >>44611332 #>>44613040 #
2. tcfhgj ◴[] No.44611332[source]
no

https://doc.rust-lang.org/std/future/macro.join.html

replies(1): >>44612037 #
3. sedatk ◴[] No.44612037[source]
Then it doesn’t apply in this case.
replies(1): >>44615353 #
4. deathanatos ◴[] No.44613040[source]
Why is having it be syntax necessary or beneficial?

One might say "Rust's existing feature set makes this possible already, why dedicate syntax where none is needed?"

(…and I think that's a reasonably pragmatic stance, too. Joins/selects are somewhat infrequent, the impediments that writing out a join puts on the program relatively light… what problem would be solved?

vs. `?`, which sugars a common thing that non-dedicated syntax can represent (a try! macro is sufficient to replace ?) but for which the burden on the coder is much higher, in terms of code readability & writability.)

5. tcfhgj ◴[] No.44615353{3}[source]
why?