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: nob...@puremagic.com
        ReportedBy: luka8...@owave.net


--- Comment #0 from luka8088 <luka8...@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: -------

Reply via email to