dotty-feature-requests
dotty-feature-requests copied to clipboard
Support async/await natively
Like https://github.com/scala/scala-async
Dsl.scala is more general than scala.async. I am trying to port compiler plugins in Dsl.scala to Dotty.
There are two compiler plugins in the Dsl.scala project:
BangNotationperforms function local CPS translation, which originally implemented as anAnalyzerPlugin. Fortunately it can be implemented as aninline macro resetin Dotty.ResetEverywhereadded aresetwrapper for every function, in other words, triggering theBangNotationtranslation for every function. Unfortunately I cannot find an approach to implement it in Dotty because Dotty does not provide an approach to trigger aninline macroin a compiler plugin.
ResetEverywhere enables syntax like Future { !Await(f1); !Await(f2) }. Without ResetEverywhere, you have to write reset(Future { !Await(f1); !Await(f2) }).
Porting ResetEverywhere is blocked by https://github.com/lampepfl/dotty/issues/7160.
I'm mildly :-1: on this. async/await in the language would require tying ourselves to a particular implementation of asynchronous effects, which would most likely be Future. If anything, I'd prefer reducing the difference between for { stats } and { stats }, so that we would be able to mix e.g. local defs with generators on anything that provides flatMap.
@kubukoz Not really. A generic language-level solution like Dsl.scala does not bind to any underlying implementation.