Very limited shared promotion

Manu turkeyman at gmail.com
Wed Jun 19 03:11:59 UTC 2019


On Wed, Jun 19, 2019 at 12:20 AM Timon Gehr via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 18.06.19 16:14, Timon Gehr wrote:
> > On 18.06.19 16:13, Timon Gehr wrote:
> >>
> >> int sum(){ // note: just to illustrate the concept
> >>      int result=0;
> >>      foreach(i;iota(1000).parallel){
> >>          static assert(is(typeof(result)==shared(int)));
> >>          result.atomic!"+="(i);
> >>      }
> >>      static assert(is(typeof(result)==int));
> >>      return result;
> >> }
> >
> > Return type should have been int, of course...
>
> And there should have been is expressions. Getting tired from pushing
> back against all the nonsense. Just note that if you can make the above
> work with useless qualified capturing, you can do so with useful
> qualified capturing and this is so blatantly obvious that it causes me
> physical pain that Manu honestly does not see it.

I can't see it because the design specifically inhibits that static
assert in the loop body.
But I will revoke my opinion on this matter; arguing will only slow it
down. If you know how to make that *EXACT* code you wrote above work,
then we are done here and I will buy you a years supply of beer.

Coupled with removing read/write access from shared, that is
everything I need to go away and leave you all alone.


More information about the Digitalmars-d mailing list