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..

Reply via email to