Re: How do I do this?

2017-08-04 Thread Kagamin via Digitalmars-d
dmd has a feature that a file passed directly to the compiler overrides file system for module search. reallogger/impl/pluglogger.di --- module mylogger.logger; public import reallogger.impl.logger; --- main.d --- import mylogger.logger; ...stuff --- dmd main.d - imports mylogger/logger.d dmd m

Re: How do I do this?

2017-08-03 Thread wxcvb via Digitalmars-d
On Thursday, 3 August 2017 at 10:46:06 UTC, Shachar Shemesh wrote: The problem: I'm writing a library. This library has logging facilities, but where it's going to be used there are better logging facilities. Under C, that wouldn't be a big issue: log.h: #ifdef REAL_LOG_LIBRARY #include REAL_L

Re: How do I do this?

2017-08-03 Thread Johan Engelen via Digitalmars-d
On Thursday, 3 August 2017 at 12:33:54 UTC, Andrei Alexandrescu wrote: There's a bit of irony you can read a file during compilation but not pass a string. I always wondered about this. It makes things more cumbersome than needed. Is it a conscious decision to not allow passing a string dir

Re: How do I do this?

2017-08-03 Thread Andrei Alexandrescu via Digitalmars-d
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 implementati

Re: How do I do this?

2017-08-03 Thread Shachar Shemesh via Digitalmars-d
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 thi

Re: How do I do this?

2017-08-03 Thread Adam D. Ruppe via Digitalmars-d
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 bac

Re: How do I do this?

2017-08-03 Thread ketmar via Digitalmars-d
Shachar Shemesh wrote: Under D, there is no facility to transfer a string from the command line to the code, so I can't use that approach. module a; void mylog (string) { ... } module b; void mylog (string) { ... } module c; version(loga) import a; else import b; .. mylog("boo!"); ..

How do I do this?

2017-08-03 Thread Shachar Shemesh via Digitalmars-d
The problem: I'm writing a library. This library has logging facilities, but where it's going to be used there are better logging facilities. Under C, that wouldn't be a big issue: log.h: #ifdef REAL_LOG_LIBRARY #include REAL_LOG_LIBRARY #else // Declarations go here #endif I can now inject