Open icholy opened 10 years ago
I like it...
Nice idea (although the Map function should possibly transform from ThingA to ThingB).
Peter Welch (inventor of the parallel sort algorithm, amongst other things) often talks about channels and goroutines (a.k.a. 'processes') in terms of Lego-like building bricks (more: http://www.cs.kent.ac.uk/projects/ofa/jcsp/). If Gen were to generate code for channel-based generic processes, some of Welch's ideas should be considered.
However, defining a useful set of operations is a rather open-ended task, I fear.
I've written a demo typewriter for pipelines here. It's only about an hour's work so there are definitely rough spots. The biggest challenge with this is early termination. I've had to wrap the channel in a struct instead of just adding methods to it in order to allow an early close feature, but I think it leads to a simple enough api.
It would be cool if it could generate similar methods that work on channels.
Something like: http://play.golang.org/p/wr1nZgxi1m