How do I do this?
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 3 03:59:43 PDT 2017
On Thursday, 3 August 2017 at 10:46:06 UTC, Shachar Shemesh wrote:
> I seem to remember that D had an option of importing an
> external file as something (string? code? anything would do for
> my purposes). I cannot seem to find it, however. A search for
> "string import" and "import mixin" brought back nothing useful.
import("path/to/file") takes a file's contents as a string and
you can mixin it. Needs -Jbase/path passed to dmd.
But he way I'd do this is to actually write two files for the
same module:
old_log.d
module logging;
// declarations
new_log.d
module logging;
// declarations
Then when you compile, do `dmd mainmodule.d old_log.d` to use the
old one and `dmd mainmodule.d new_log.d` to use the new one. In
mainmodule, you `import logging;` and the file passed on the
command line is the one it will refer to.
Though, if you have a complex build this might be trickier.
More information about the Digitalmars-d
mailing list