[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pop-dev] Go - a new language from Google

On Thu, Nov 12, 2009 at 4:38 PM, P.H.Welch <P.H.Welch@xxxxxxxxxx> wrote:
> Hi Carl,
>> Sequential delta? yes
> How elegant does a parallel delta look in go?  I've still not looked
> at go enough.  It has a FORK, but does it have a PAR (i.e. FORK-JOIN)?

You have to manually do a FORK-JOIN, which is part of the problem that
I'm having with it.  The only way to "wait" on a process finishing is
to give that process a channel and then wait on it.  There's no
poisoning or anything like it, just the ability to close channels,
which works like this.

a = make(chan int);
if closed(a) {
  // This won't happen, because the channel hasn't been read from yet

foo := <-a;
// This read from a closed channel, which returns the zero value for the
// type, so foo is 0.

if closed(a) {
  // This finally happens

All of this together with a lack of currying and some other nice
features, means that writing a PAR construct that ensures all of its
components terminate before proceeding is a bit difficult.  The
problem is thus:

  * Each process in the PAR needs to be given a channel that they can
use to signal they are finished with their computation
  * There is no way to do vararg functions that I've found, so having
a "dispatch" wrapper that does just this is not easy to write.

I came up with the attached code that lets me get CLOSE to having a
nice syntax.. but it's too complex by far.  It's 80 lines, or I would
have included it inline =).

Jim Whitehead
Oxford University Computing Lab

Attachment: process.go
Description: Binary data