4 ms·
Show HN: Short Implementation of Goroutines in Swift
- Xorlev 12y agoThe rough part will be implementing select, the rest is pretty straightforward in comparison.
- deleted 12y ago[deleted]
- deleted 12y ago[deleted]
- jmgrosen 12y agoHow you implement that channel operator is really hacky. I love it.
- billylindeman 12y agoYeah, 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 12y agoI just wondered, do you know whether operators are namespaced? Or whether that's possible?
- billylindeman 12y agoNot 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.
- koblas 12y agoIt'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.
- ZitchDog 12y agoI'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/go.swift#L55 https://github.com/billylindeman/swiftgo/blob/master/swiftgo...
- billylindeman 12y agoderp. 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
- skj 12y agoWithout select, you don't have goroutines.