[Issue 8993] New: Implement unique references/isolated memory

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 10 06:40:11 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8993

           Summary: Implement unique references/isolated memory
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: sludwig at outerproduct.org


--- Comment #0 from Sönke Ludwig <sludwig at outerproduct.org> 2012-11-10 06:40:09 PST ---
'unique' or 'isolated' is a recursive type qualifier which enforces that there
is only a single reference to a given piece of memory, and that the memory
itself is only pointing to other data that is either immutable, or only
referenced within the same memory cluster.

Any value/reference that is tagged this way can safely be converted to
immutable or can safely be passed (moved) to another thread. In conjunction
with (weakly) pure functions it is possible to operate almost freely on a
unique value, because it can be guaranteed that no visible additional
references can be created.

The main advantages of this approach are:

 - Provides a powerful alternative to safely pass mutable data between threads
without requiring locks or synchronization primitives (synchronized/shared)

 - Construction of immutable objects can be done in a natural procedural
fashion and not only within the object constructor or within a pure function

 - Fully compatible with the current type system, builds nicely on top of the
current base

 - The system is proven both in theory and in practice

Microsoft has released a paper describing the system in form of an extension to
C#. The paper includes formal proofs for the soundness of the system and
mentions a multi-million lines of code project for which it is used:

http://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf

D specific and in addition to the Microsoft paper, a solution to support
partitioning of a uniqe array with unique slices as the result is desirable.
But this can be done as a simple library function if needed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list