keyword-generics-initiative
keyword-generics-initiative copied to clipboard
Mention golang go keyword as alternative to async let
Finally got around to reading #54 and I think that golang's go
keyword should be mentioned as a direct alternative to async let
from Swift. They perform similar operations, and the only difference is that golang doesn't actually allow capturing the return value from the operation, which could easily be rectified by making the expression return a future.
Essentially, I'm quite averse to the async let
syntax since it seems to disrupt the purity of let
as an operation: let
is just assigning something, but async let
is spawning a task and defining a handle to it, which feels a bit too overloaded. A very valid alternative would be to simply spawn a task and assign that to the let, i.e.:
let task = defer!(my_expression);
And if we were to implement async drop, then:
let _ = defer!(my_expression);
would be enough to simply defer the task until the end of the block.