[Issue 6274] New: 'pure' for a whole struct definition

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 8 18:08:37 PDT 2011


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

           Summary: 'pure' for a whole struct definition
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-07-08 18:03:32 PDT ---
Just like "final" applied to a class makes all its methods non-virtual:


final class Foo {
    int x;
    this(int xx) { x = xx; }
    void bar() {}
    static void spam() {}
}
void main() {}



I'd like the attribute "pure" applied to a struct/class (in DMD 2.054beta this
doesn't compile):

pure struct Foo {
    int x;
    this(int xx) { x = xx; }
    void bar() {}
    static void spam() {}
}
void main() pure {
    Foo f = Foo(1);
    f.bar();
    Foo.spam();
}


to be equivalent to adding "pure" to all its methods:

struct Foo {
    int x;
    this(int xx) pure { x = xx; }
    void bar() pure {}
    static void spam() pure {}
}
void main() pure {
    Foo f = Foo(1);
    f.bar();
    Foo.spam();
}

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