11 comments

[ 3.2 ms ] story [ 31.3 ms ] thread
How you implement that channel operator is really hacky.

I love it.

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.
I just wondered, do you know whether operators are namespaced? Or whether that's possible?
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.
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.
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...

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
The rough part will be implementing select, the rest is pretty straightforward in comparison.
(comment deleted)
(comment deleted)
Without select, you don't have goroutines.