[Issue 8785] New: feature request: static mixin

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 8 13:01:26 PDT 2012


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

           Summary: feature request: static mixin
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: luka8088 at owave.net


--- Comment #0 from luka8088 <luka8088 at owave.net> 2012-10-08 12:43:25 PDT ---
Currently, there is no way of encapsulating mixin templates as static keyword
has no effect.

import std.stdio;

mixin template myTemplate () {
  void fn () {
    writeln("myTemplate");
  }
}

struct myStruct {
  static mixin myTemplate t1; // static keyword has no effect
}

void main () {
  myStruct s1;
  s1.t1.fn(); // myTemplate
  s1.fn(); // myTemplate
}

I would kindly request that static keyword encapsulates the template members so
that s1.fn is not directly accessible but rather only as s1.t1.fn

One hack proposal was to use

static struct t1 {
  mixin myTemplate;
}

but that turned out to be a bed idea because in that case mixin code can't use
this to access myStruct

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