gccgo provides an API to its Go runtime implementation so I used that to create a library made of C and Go code that can be used from C: https://github.com/stefantalpalaru/golib
Using golib and some macro abuse, I brought Go's channels and goroutines to Nim in a form that's quite close to the original syntax: https://github.com/stefantalpalaru/golib-nim
Now golib-nim can't use any of the provided garbage collectors (it runs with --gc:none, but where's the fun in that?) so I had to implement Go's garbage collector in Nim: https://github.com/stefantalpalaru/Nim
And here's the pull request: https://github.com/Araq/Nim/pull/2851
To sum up the dependencies:
I've especially liked the implementation of "scase". It really shows the power of Nim's macro system.
What is the goal here? Do you want to use Go's channels because they are better than Nim's channel? Or because you want to compile Nim and Go code together (e.g. pass a value on a channel from Nim to Go)? Or both?
Thanks, Peter
Go's channels have more features than Nim's ones (http://nim-lang.org/docs/channels.html) and the select on multiple channels is particularly useful. Even in the gccgo implementation they have seen significant battle testing and refinement.
What is the goal here?
The main goal is to use Go's M:N threading and CSP inspired concurrency model. The channels come as a great fit for goroutines and allow me to copy some of Go's syntax and idioms.
Tonight after reading this thread i started looking for C implementations for goroutines. I found this project developed by the original creator of ZeroMQ http://libmill.org/
I think that someone should wrap this library and create a nimble package.
This thread is linked to from Hacker News, with 45+ comments - https://news.ycombinator.com/item?id=9640384 :D
And (featuring my own twisted sense of humor) - https://www.facebook.com/copyfree.org/posts/391079504417368 :P