[dmd-concurrency] shared arrays
Steve Schveighoffer
schveiguy at yahoo.com
Thu Jan 14 11:41:49 PST 2010
----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
> To: Discuss the concurrency model(s) for D <dmd-concurrency at puremagic.com>
> Sent: Thu, January 14, 2010 2:36:47 PM
> Subject: Re: [dmd-concurrency] shared arrays
>
> Steve Schveighoffer wrote:
> > What about shared(T)[] where T.sizeof >= 2*(size_t.sizeof) ? If copying an
> array reference is unusable, then why is copying large array elements usable?
> This whole point has confused me...
> >
> > Should the runtime throw an exception when asked to copy such arrays?
>
> It's a compile-time error. Assignment of shared values is defined only for types
> up to word-size that don't define constructors. If this doesn't compile:
>
> foreach (i; 0 .. a.length) b[i] = a[i];
>
> then this shouldn't compile either:
>
> b[] = a[];
or these?
b.dup;
T t;
b ~= t;
b ~= a;
But really, I don't understand why it's ok to copy i.e. a shared(char)[] where half of it might have changed, but it's not OK to copy an array of large types.
Does this also mean that shared(long) isn't usable? Isn't that a bit limiting?
-Steve
More information about the dmd-concurrency
mailing list