[Issue 14681] Add a way to specify a file import's contents on the command line

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 25 22:59:12 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14681

--- Comment #5 from yebblies <yebblies at gmail.com> ---
(In reply to Walter Bright from comment #4)
> The version feature is deliberately restrictive. Setting variables from the
> command line is most often a failure to design the code properly. I don't
> think it is a good idea.
> 
> Do you have a compelling use case for it?

Passing strings in from the command line is sometimes quite useful.  Some
examples from DMD would be:
 -J:SYSCONFDIR=/etc/dmd.conf
 -J:VERSION=2.068

Another would be to easily embed a build id in the binary.

The next-best solution is to write these values to a file first, but that
brings with it several complications.  Sometimes all you need is a short
string, and this provides an convenient and safe version of the C preprocessor
solution.

I certainly don't think this should be used to replace version(), but I think
the syntax is enough of a disincentive to avoid that.

eg static if (import(":mode") == "something") {}

--


More information about the Digitalmars-d-bugs mailing list