Am 14.06.2012 20:01, schrieb Artur Skawina:
On 06/14/12 19:26, Pragma Tix wrote:
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.
mixin template StdLib()
{
import std.string;
import std.stdio;
}
mixin StdLib!() stdlib;
The 'mixin' part is not necessary:
template StdLib() {
import std.string;
import std.stdio;
}
alias StdLib!() stdlib;
but you don't even need a template:
struct stdlib { import std.string, std.stdio; }
artur
That's pretty cool. thanks. Is this struct {import ...}feature
documented.. somewhere ?