On 08/03/2017 07:00 AM, Shachar Shemesh wrote:
No sooner did I send out this question I have found the D feature I've
been looking for. This is what I have:
module log;
version(alternate_logger) {
mixin("public import " ~ import("alternate_logger.txt") ~ ";");
} else {
// Default implementation goes here
}
Can't say I'm thrilled with this, but it does get the job done.
Suggestions more than welcome.
There's a bit of irony you can read a file during compilation but not
pass a string.
The version can be dropped as well, but always requires the existence of
the intermediate file:
private alternateLogger = import("alternate_logger.txt");
static if (alternateLogger.length) {
mixin("public import " ~ alternateLogger ~ ";");
} else {
...
}
Andrei