

Show HN: Short Implementation of Goroutines in Swift - billylindeman
https://github.com/billylindeman/swiftgo

======
Xorlev
The rough part will be implementing select, the rest is pretty straightforward
in comparison.

------
skj
Without select, you don't have goroutines.

------
ZitchDog
I'm a little confused - when you say "should write value to pipe or block
until it can"[1] - I don't see how this will block, it looks like it will just
return if the pipe is full. I confess to be only a little bit familiar with
GCD!

[1]
[https://github.com/billylindeman/swiftgo/blob/master/swiftgo...](https://github.com/billylindeman/swiftgo/blob/master/swiftgo/go.swift#L55)

~~~
billylindeman
derp. yeah i wrote the comments before i coded it. I'll probably revise this
section at some point. I still want to figure out if implementing select{} is
possible

------
koblas
It's both amazing and horrifying the level of overloads that Swift supports.
If the early cases are done well we may avoid the C++ mantra of
overloading==evil.

------
jmgrosen
How you implement that channel operator is _really_ hacky.

I love it.

~~~
billylindeman
Yeah, I had to make due with the docs available on my machine. I only started
this cause my in-flight internet went offline. The ability to make your own
operators is pretty damn cool, and pretty damn scary as well. I have a feeling
that in the coming months, many libraries will abuse the shit out of this
feature.

~~~
terhechte
I just wondered, do you know whether operators are namespaced? Or whether
that's possible?

~~~
billylindeman
Not exactly from what I understand, but the operator definition is just
telling swift that '<-' is a usable prefix and infix. To actually use them on
an object you need to have class/struct specific implementations of the
function.

