Pre SIP: `for` with Control Flow (an alternative to Scala Async, Scala Continuations and Scala Virtualized)

Currently dotty-cps-async supports types other than Future (and event interoperability between different types of monads and automatic colouring, which is impossible in untyped case).
If exists some corner cases, where something is impossible to express in typed form – it would be great to look and analyze them. I can’t find one.

//about proposed language changes itself:

  • the part about if in for is great, it’s intuitive, can clear semantics for collections and can be implemented without risk. (although I prefer to have 2 translations for sync and async conditions)
  • in match I afraid about nesting .right expression ‘k-times’.
  • block part looks unfinished or too restrictive (not specified, how to handle ← expression inside stats).
  • next steps having x ← y instead x = await(x) wrapped in some async expression: the value for developer will be the value of avoiding àsync brackets on top of each function.
  • This can be an interesting theme for research in the middle-term, two things which come to mind:
    – a) if we want ‘lift’ type of monad to the type of DSL expression, then we would have untrivial inference with typing;
    – b) proposal as specified less powerful than existing async wrappers, where while-s and nested blocks are supported.
    This can be fixed in the long run after research.
  • also specifying concrete rules in specification prevent optimizations (for example, dotty-cps-async have different patterns when all subexpression are async or some not, so we have no more than minimum nesting of monads applications. )

If anybody want to count my opinion in the short term — I see adopting ìf` can be factored out to small and nice change.

1 Like