dotty-feature-requests icon indicating copy to clipboard operation
dotty-feature-requests copied to clipboard

Support async/await natively

Open benwaffle opened this issue 6 years ago • 4 comments

Like https://github.com/scala/scala-async

benwaffle avatar Aug 29 '19 17:08 benwaffle

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:

  1. BangNotation performs function local CPS translation, which originally implemented as an AnalyzerPlugin. Fortunately it can be implemented as an inline macro reset in Dotty.
  2. ResetEverywhere added a reset wrapper for every function, in other words, triggering the BangNotation translation for every function. Unfortunately I cannot find an approach to implement it in Dotty because Dotty does not provide an approach to trigger an inline macro in a compiler plugin.

Atry avatar Sep 03 '19 06:09 Atry

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.

Atry avatar Sep 03 '19 07:09 Atry

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 avatar Oct 10 '19 00:10 kubukoz

@kubukoz Not really. A generic language-level solution like Dsl.scala does not bind to any underlying implementation.

Atry avatar Oct 10 '19 01:10 Atry