Go: A new system programing language

Robert Jacques sandford at jhu.edu
Thu Nov 12 17:31:04 PST 2009


On Thu, 12 Nov 2009 15:01:24 -0500, Joel C. Salomon  
<joelcsalomon at gmail.com> wrote:

> On 11/11/2009 8:47 PM, dsimcha wrote:
>> == Quote from Walter Bright (newshound1 at digitalmars.com)'s article
>>> hasenj wrote:
>>>> Do you think D would benefit if you add this (or similar) feature to  
>>>> it?
>>> Sean is working on a message passing (CSP) package for D. I'm not
>>> convinced it needs to be a core language feature, though.
>>
>> This is true.  After I created ParallelFuture (the lib w/ parallel  
>> foreach, map,
>> reduce), a friend mentioned that my model was pretty similar to the  
>> OpenMP model.
>>   I read a little about OpenMP and it really hit home how powerful a  
>> language D is,
>> given that I was able to implement something OpenMP-ish as a pure  
>> library, without
>> any modifications to the compiler.  The fact that message passing is  
>> built into
>> Go! makes me wonder if there's a reason why it can't be done well in a  
>> library.
>
> Most stuff can be done decently well in a library -- imagine Plan 9’s  
> libthread with channels implemented input/output ranges.  Select is ugly  
> though, without some language support; perhaps D’s compile-time stuff  
> can implement a select block.
>
> —Joel Salomon

Ugly? I'm pretty sure you could do the following in D:

select(
     guard(chan1, x = chan1.value;),
     guard(chan2, y = chan2.value;),
     guard(true , writeln("always triggers") )
);

Aren't lazy variables grand :)



More information about the Digitalmars-d mailing list