www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Joe Duffy on concurrency

reply Barry <barry.lapthorn gmail.com> writes:
http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/

D gets a brief, but good plug:

D
The system we came up with has obvious comparisons to D’s take on 
const and immutable; just as D’s const is a view over mutable or 
immutable data, so too is our readonly. And just as D added 
deepness to the concept of const, so did we in our permissions 
model generally. This is perhaps the closest analogy in any 
existing systems. I am frankly surprised it doesn’t get used an 
order of magnitude more than it does, although Andrei, one of its 
chief developers, has some thoughts on that topic.
Dec 01 2016
parent reply qznc <qznc web.de> writes:
On Thursday, 1 December 2016 at 12:17:46 UTC, Barry wrote:
 http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
 delegate void PureFunc<T>() immutable;
 This meant that a lambda conforming to the PureFunc interface 
 could only close over immutable state.
 Notice how powerful this has suddenly become! This PureFunc is 
 precisely what we would want for a parallel task. As we will 
 see shortly, these simple concepts alone are enough to enable 
 many of those PFX abstractions to become safe.
That is an interesting idea. Afaik, D does not allow to limit closure like this?
Dec 01 2016
next sibling parent reply Dicebot <public dicebot.lv> writes:
On Thursday, 1 December 2016 at 18:56:36 UTC, qznc wrote:
 That is an interesting idea. Afaik, D does not allow to limit 
 closure like this?
void i_only_accept_immutable_context (void delegate () immutable closure);
Dec 01 2016
parent Dicebot <public dicebot.lv> writes:
On Thursday, 1 December 2016 at 19:14:51 UTC, Dicebot wrote:
 On Thursday, 1 December 2016 at 18:56:36 UTC, qznc wrote:
 That is an interesting idea. Afaik, D does not allow to limit 
 closure like this?
void i_only_accept_immutable_context (void delegate () immutable closure);
NB: it may have ton of bugs though, because delegate context suffers from type erasure in runtime
Dec 01 2016
prev sibling parent Meta <jared771 gmail.com> writes:
On Thursday, 1 December 2016 at 18:56:36 UTC, qznc wrote:
 On Thursday, 1 December 2016 at 12:17:46 UTC, Barry wrote:
 http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
 delegate void PureFunc<T>() immutable;
 This meant that a lambda conforming to the PureFunc interface 
 could only close over immutable state.
 Notice how powerful this has suddenly become! This PureFunc is 
 precisely what we would want for a parallel task. As we will 
 see shortly, these simple concepts alone are enough to enable 
 many of those PFX abstractions to become safe.
That is an interesting idea. Afaik, D does not allow to limit closure like this?
Actually it does, and it works the exact same way as far as I can tell. void main() { int n; int nested() immutable { return n; //Error: immutable function 'f761.main.nested' cannot access mutable data 'n' } auto del = () immutable => n; //Error: immutable delegate 'f761.main.__dgliteral2' cannot access mutable data 'n' }
Dec 01 2016