Immutable and unique in C#

Robert Jacques sandford at jhu.edu
Sun Nov 11 09:20:20 PST 2012


On Fri, 09 Nov 2012 07:53:27 -0600, Sönke Ludwig <sludwig at outerproduct.org> wrote:

> Just stumbled over this, which is describing a type system extension for
> C# for race-free parallelism:
>
> http://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf
>
> Independent of this article I think D is currently missing out a lot by
> omitting a proper unique type (a _proper_ library solution would be a
> start, but I'm not sure if that can handle all details). It would make a
> lot of the cases work that are currently simply not practical because of
> loads of casts that are necessary.
>

What's wrong with std.typecons.Unique?
By the way, back when concurrency in D was actively being discussed and developed, (IIRC) Walter did try to implement unique as a proper type in D, but ran into several gotchas. In essence, while we all want unique/mobile, for unique/mobile to be non-broken it also needs at least a lent/scope and an owned type. Ownership type systems are a relatively new area of CS and as demonstrated by the paper, still an active area of research. The thorny issue of these systems is that you need to associate variables with types. For example, this.x = that.y; is only valid if x and y are both owned by the same region. This is easy to verify at runtime, but not at compile-time. Anyways, ownership types (or whatever supersedes them) were pushed back to D3 and we were left with message passing for the common user, synchronized for traditional lock-based shared memory and shared for lock-free programming.

P.S. Thanks for the link to the paper.


More information about the Digitalmars-d mailing list