Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Aleksandar Prokopec
    @axel22
    with yieldval statements inside each most nested while loop
    and check if the yieldval occurs in the coroutine as many times as expected
    the check would happen in a ScalaCheck property.
    The basic challenge is to write the generator for sufficiently complex tree, but for which you know what the output should be.
    I would start simple, with coroutines that only have a sequence of yieldval statements, one after another (no loops, try-catches, if-statements, etc.)
    Chao Chu
    @chuchao333
    Thanks! If you don't mind, I would'd like to create an issue in the coroutines repo with what you described documented there and assign the issue to myself?
    Aleksandar Prokopec
    @axel22
    Sure, please go ahead!
    Maximilan Csuk
    @IMakeGames__twitter
    Hi! :) I recently started using scala coroutines and I really like them! But I've run across something: there seems to be a limit for how many sub-coroutines can be called from a coroutine... and that limit is exactly 30. What's up with that?
    You can get around that by "sub-coroutining" again so that each coroutine has no more than 30 coroutine function calls though
    Maximilan Csuk
    @IMakeGames__twitter
    Error message(s) is/are "method $ep30 overrides nothing", "method $ep31 overrides nothing", etc..
    Aleksandar Prokopec
    @axel22
    Hi! Thanks for reporting this! Ok, I think I know what is causing this - definitely a bug, there should be no limit. If you have a minimal example, feel free to open an issue, otherwise I'll open one.
    Maximilan Csuk
    @IMakeGames__twitter
    I opened an issue here: storm-enroute/coroutines#21
    Thanks for looking into this! : )
    Aleksandar Prokopec
    @axel22
    Thanks! Will take a look soon!
    Walter Chang
    @weihsiu
    can i use coroutines in scala.js like i can with scala async?
    S├ębastien Doeraene
    @sjrd
    @weihsiu AFAICT, coroutines have a runtime component, unlike async. So scala-coroutines needs to be cross-built and published for Scala.js.
    Aleksandar Prokopec
    @axel22
    @weihsiu As Sebastien says, we would need to cross-compile Coroutines to Scala.JS. However, I don't think this should require any modifications to the current source code, cross-compilation should work out-of-the-box.
    Walter Chang
    @weihsiu
    @sjrd @axel22 am i right to assume a modification of the build file with the usage of crossProject and inclusion of the scala.js plugin are necessary?
    S├ębastien Doeraene
    @sjrd
    Yep, that's right.
    Hanns Holger Rutz
    @Sciss
    Hi. What's the status of this project? It's kind of sad to see the front page on GitHub with Travis failing to compile the project half a year back.
    megri
    @megri
    I would love good support for coroutines in Scala. Would it be possible to forego the explicit coroutine call shown in the async/await example using something like implicit function types from Dotty?
    Hanns Holger Rutz
    @Sciss
    @megri I think the problem is the macros - they don't really compose, so for async to work without taking a coroutine { }, it would have to be a macro itself. (I might be wrong)
    One thing I find annoying is the : Any return type for coroutines; it means IntelliJ freaks out completely. Why can't the return type be correctly given by the macro method?

    Like, why doesn't

    coroutine { () => yieldval(3) }

    have a before-macro expansion known type of Coroutine._0[Int, Unit] instead of Any?

    Maximilan Csuk
    @IMakeGames__twitter
    Just throwing this out here: I can't contribute much because the project is way over my head in terms of Scala knowledge, but I'm an avid user and would love to migrate to scala 2.12 with my current project and keep coroutines. :)
    Hanns Holger Rutz
    @Sciss
    What is the reason we cannot abstract over Coroutine._0[Y, R] and ~~~>[Y, R]? So one has to overload stuff like
      implicit def lift[A](co: Coroutine._0[A, _]): Iterator[A] = new CoroutineIterator[A](call(co()))
      implicit def lift[A](co: ~~~>        [A, _]): Iterator[A] = new CoroutineIterator[A](call(co()))
    in other words, can't DefMarker have two type parameters trait DefMarker[Y, R] and provide the common interface method apply?
    Hanns Holger Rutz
    @Sciss

    Can somebody explain this to me:

    coroutine { () => for (_ <- 0 until 3) yieldval(3) }

    Error:

    Error:(81, 60) The yieldval statement only be invoked directly inside the coroutine. Nested classes, functions or for-comprehensions, should either use the call statement or declare another coroutine.

    How do I use the call statement here?

    Maximilan Csuk
    @IMakeGames__twitter
    I tried to run your code and the closest I got was:
    val inner = coroutine { (a: Int) => yieldval(a) }
    coroutine { (a: Int) =>
      for (_ <- 0 until 3) {
       call(inner(3))
      }
    }
    Hanns Holger Rutz
    @Sciss
    @IMakeGames__twitter ok, thanks. It would be great if for-comprehensions, at least where they are clearly iterations over a range, could be "inlined" somehow. I don't know how difficult it would be to match and rewrite them. There is a project that tries something (again with macros): https://github.com/nativelibs4java/Scalaxy/tree/master/Loops
    Another question I have is why coroutines needs whitebox macros and is formally untyped def coroutine[Y, R](f: Any): Any. Couldn't that be made to have the correct types directly? It makes the project very ugly to use in an IDE such as IntelliJ. Perhaps one can just add another method for coroutine0? Like def coroutine0[Y, R](f: () => R): Coroutine._0[Y, R]?
    Hanns Holger Rutz
    @Sciss
    Of course it would be nice to have partial type application, so you don't have to explicitly give R in the invocation, just Y.
    Cantor Chron
    @cantor-chron
    @Sciss You should use:
    coroutine { () =>
      var i = 0
      while (i < 3) {
        yieldval(3)
      }
    }
    The coroutine transformation does not cross the boundaries of the lambdas and external functions like foreach. The example could work if you declared a foreach that takes a coroutine on Ranges - without that, you need to use a while loop.
    The coroutine macro could maybe be overloaded to take functions with different arity.
    Then it could be a whitebox macro.
    Jonathan
    @b-studios
    Hey @axel22, is there anything written down (paper, docs, ...) on the internals of your co-routines library, such as descriptions of the macro transformations? Or should I start by looking into the code?
    Aleksandar Prokopec
    @axel22
    Hey Jonathan! There is no publication yet, but there is another implementation under way for Dotty. Stay tuned!
    Hanns Holger Rutz
    @Sciss
    @axel22 Oh, that's great news -- so is that a compiler plug-in then, or does Dotty already have a macro system?
    Jonathan
    @b-studios
    Amazing @axel22! I'd also be interested in how you achieve this. Plugin or byte choose instrumentation?
    Aleksandar Prokopec
    @axel22
    It will essentially be using the new metaprogramming API: https://github.com/scalacenter/macros
    This is still in early stages, and Fengyun Liu is working on this on the EPFL side.
    But as soon as there is something more tangible and production ready, it will be announced more widely.
    Hanns Holger Rutz
    @Sciss
    :thumbsup:
    jtodd5578
    @jtodd5578
    Which part can I check for co-routine mechanism in https://github.com/scalacenter/macros?
    Aleksandr Bezhan
    @alexbezhan
    Hey guys. Is there a "channel" abstraction ?
    Henry Story
    @bblfish
    Hi, I came across corountines after asking a question on how to serialise Free Monads for a use case case of mine where I used them with Akka actors in order to allow just-in-time interpretation of the Free Monad so that each command could be interpreted in a different way (the interpretation happening at the moment of execution of the command). The details are here typelevel/spotted-leopards#3
    It seems one is faced with a choice of having a stack-safe free monad without serialisation or using the stack and having serialisation.
    I get the feeling that coroutines would allow one to have both. Is that right?
    Henry Story
    @bblfish
    It looks like I don't actually need stack safety in my case, as each instruction is exectuted by a different akka actor.