[Issue 10012] New: [2.063 beta] pure constructors taking POD structs should be allowed for shared/immutable construction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 30 02:04:12 PDT 2013


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

           Summary: [2.063 beta] pure constructors taking POD structs
                    should be allowed for shared/immutable construction
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: sludwig at outerproduct.org


--- Comment #0 from Sönke Ludwig <sludwig at outerproduct.org> 2013-04-30 02:04:08 PDT ---
The following snippet errors out:

---
struct S { }
class Test2 { this(S) pure {} }

void main()
{
    auto test2 = new shared Test2(S());
    auto test3 = new immutable Test2/(S());
}
---

test_shared.d(7): Error: mutable method test_shared.Test2.this is not callable
u
sing a immutable object
test_shared.d(7): Error: incompatible types for ((new immutable(Test2)) /
(S()))
: 'immutable(Test2)' and 'S'

However, since any instance of S is an independent copy, the resulting object
is still unique and thus should be liable for immutable or shared object
construction. Also, in addition to POD types, types containing only immutable
references should be allowed.

Finally, shared references can also be allowed when constructing a shared
object, but this is a different kind of "unique" or "isolated" concept - I call
it "weakly isolated" in my library implementation [1] following the "weakly
pure" nomenclature - so this may need some bigger changes.

[1]
https://github.com/rejectedsoftware/vibe.d/blob/6c9efa2fdcef1797c84e58483410f262a2a82d67/source/vibe/core/concurrency.d#L958

-- 
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