www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2131] New: Template scope access


           Summary: Template scope access
           Product: D
           Version: 2.014
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: simen.kjaras gmail.com

In my post "Template alias parameter mixin import inference" (
), and in bug 2125 ( http://d.puremagic.com/issues/show_bug.cgi?id=2125,
"Moving a template to a separate module breaks compilation" ), it is
demonstrated that giving a template access to both its declaration scope and
its instantiation scope might give more logical and desireable behavior.

Example code:


module a;
import std.stdio;

template bar()
        int i;

        void func()

void main()
        foo!(bar) a;


module b;

struct foo(alias T)
        mixin T!();


Gives error message "b.d(5): Error: undefined identifier writefln".

Currently, this can be fixed by placing import statements within the template
declaration, but allowing access to more scopes would make it easier for the

May 25 2008