[Issue 1734] New: Inconsistant mixin behaviour

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 16 11:10:12 PST 2007


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

           Summary: Inconsistant mixin behaviour
           Product: D
           Version: 2.008
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: aarti at interia.pl
 BugsThisDependsOn: 1732


Currently templates can consists only from declarations, so it's not possible
to put there statements. It causes following:
below does not compile:
-------------------
template init() {
   a = 5;
}

void main() {
  int a;
  mixin init;
}
-------------------

but below compiles:
-------------------
import std.stdio;

template init() {
   void func() {writefln(a);}
}

void main() {
  int a;
  mixin init;
  func();
}
--------------------

while both template bodies are syntacticly wrong.

------------

I think that statements should be allowed in templates or another mechanism
should be introduced and template mixins should be depreciated.


-- 



More information about the Digitalmars-d-bugs mailing list