{"id":23360894,"url":"https://github.com/satabin/gnieh-coroutines","last_synced_at":"2025-04-07T20:52:21.156Z","repository":{"id":1121161,"uuid":"993475","full_name":"satabin/gnieh-coroutines","owner":"satabin","description":"Scala compiler plugin to support coroutines","archived":false,"fork":false,"pushed_at":"2010-12-03T16:56:20.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T22:36:41.144Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satabin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-16T22:14:16.000Z","updated_at":"2013-10-10T13:52:20.000Z","dependencies_parsed_at":"2022-08-16T12:05:21.267Z","dependency_job_id":null,"html_url":"https://github.com/satabin/gnieh-coroutines","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satabin%2Fgnieh-coroutines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satabin%2Fgnieh-coroutines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satabin%2Fgnieh-coroutines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satabin%2Fgnieh-coroutines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satabin","download_url":"https://codeload.github.com/satabin/gnieh-coroutines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247729929,"owners_count":20986400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T11:16:50.819Z","updated_at":"2025-04-07T20:52:21.128Z","avatar_url":"https://github.com/satabin.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"Gnieh Coroutines\n================\n\nIntroduction\n------------\n\nGnieh Coroutines is a [Scala][1] library and a compiler plugin which makes it possible to use coroutines in Scala.\nThe design is based on coroutines in LUA ([Revisiting Coroutines][2], [Coroutines in LUA][3]) and natively implements asymmetric coroutines.\n\nThis project is still at an really early stage and is not finished yet. Any comments are welcome.\n\nUsage\n-----\n\nThere are two to create and use coroutines:\n\n*   coroutines.create: create and consume the coroutine object itself\n*   coroutines.wrap: create the coroutine and wrap it into a closure that takes the same parameter as the resume method\n\nFor example\n\n    import gnieh._\n    val co = coroutines.create {\n      (i: Int) =\u003e {\n        println(\"first time: \" + i)\n        val j: Int = coroutines.yld(i + 5)\n        println(\"second time: \" + j)\n        j - 7\n      }\n    }\n    println(co.resume(2))\n    println(co.resume(5))\n\nis equivalent to\n\n    import gnieh._\n    val co = coroutines.wrap {\n      (i: Int) =\u003e {\n        println(\"first time: \" + i)\n        val j: Int = coroutines.yld(i + 5)\n        println(\"second time: \" + j)\n        j - 7\n      }\n    }\n    println(co(2))\n    println(co(5))\n\nGnieh Coroutines is based on Scala continuations, so you need to enable the Scala continuations to compile the code above:\n    scalac -Xplugin:/path/to/gnieh-coroutines-plugin.jar -cp /path/to/gnieh.coroutines-library.jar -P:continuations:enable cor.scala\n\nLimitations\n-----------\n\nThere are currently different limitations:\n\n*   coroutines.yld is only allowed in the function wrapped in the coroutine\n*   recursive calls to the function wrapped in the coroutine are not supported\n\nImplementation\n--------------\n\n*TBD*\n\nTODOs\n-----\n\n*   Support for coroutines.yld in method not directly wrapped in the coroutine:\n*      add an implicit parameter to the method passing the current coroutine\n*   Support recursive calls?\n\n[1]: http://www.scala-lang.org\n[2]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.58.4017 \"Revisiting Coroutines, Ana Lúcia de Moura and Roberto Ierusalimschy\"\n[3]: http://www.inf.puc-rio.br/~roberto/docs/corosblp.pdf \"Coroutines in LUA, Ana Lúcia de Moura, Noemi Rodriguez, Roberto Ierusalimschy\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatabin%2Fgnieh-coroutines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatabin%2Fgnieh-coroutines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatabin%2Fgnieh-coroutines/lists"}