digitalmars.D.bugs - [Issue 2131] New: Template scope access
- d-bugmail puremagic.com (47/47) May 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2131
http://d.puremagic.com/issues/show_bug.cgi?id=2131 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" ( http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=68798 ), 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() { writefln(i); } } void main() { foo!(bar) a; a.func(); } ////////////////////// 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 programmer. --
May 25 2008