top | item 44609651

(no title)

raluk | 7 months ago

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.

discuss

order

jayd16|7 months ago

you mean like?

   await Join(f1(), f2())
Although more realistically

   Promise1 = f1(); Promise2 = f2();
   await Join(Promise1, Promise2);
But also, futures are the expression of lazy values so I'm not sure what else you'd be asking for.

raluk|7 months ago

This is what i hand in mind whit "manually handing of futures". In this case you have to write

   Promise1 = f1(); Promise2 = f2();
   v1,v2 = await Join(Promise1, Promise2);
   return v1 + v2
I think this is just too much of synthactic noise.

On the other hand, it is necessary becase some of underlying async calls can be order dependend.

for example

    await sock.rec(1) == 'A' && await sock.rec(1) == 'B'
checks that first received socket byte is A and second is B. This is clearly order dependant that can't be executed concurrently out of order.

sedatk|7 months ago

Which languages do have such a thing?

steveklabnik|7 months ago

Rust does this, if you don’t call await on them. You can then await on the join of both.

Twey|7 months ago

I suppose Haskell does, as `(+) <$> f1 <*> f2`.

zmj|7 months ago

That's because f2's result could depend on whether f1 has executed.