I'm having some fun with this.

import std.array;

void main()
{
    with (namespace!("std.stdio std.algorithm std.range"))
    {
        auto squares = map!("a * a")([2, 4, 6]);
        writeln(squares);
    }
}

template namespace(string x)
{
    mixin(namespaceImpl(x));
}

string namespaceImpl(string x)
{
    string result;
    auto mods = split(x);
    foreach (val; mods)
    {
        result ~= "import " ~ val ~ ";";
    }
    return result;
}

Reply via email to