Code-File structure
    Pragma Tix 
    pragmatix at orange.fr
       
    Thu Jun 14 10:26:17 PDT 2012
    
    
  
Am 13.06.2012 03:56, schrieb Nathan M. Swan:
> You cannot put multiple modules in a file like C++ namespaces.
A nice trick in D for creating local namespaces that combine items from 
several modules under one name is to use a mixin template.
module app;
mixin template StdLib()
{
    import std.string;
    import std.stdio;
}
mixin StdLib!() stdlib;
void main()
{
	int x,y =1;
	stdlib.writefln("hello");
	string s = stdlib.format("%s, %s", x,y);
	stdlib.writefln(s);
}
untested..
    
    
More information about the Digitalmars-d-learn
mailing list