On Friday, 12 July 2013 at 22:46:39 UTC, Justin Whear wrote:
On Sat, 13 Jul 2013 00:36:21 +0200, Peter Alexander wrote:

On Friday, 12 July 2013 at 20:42:50 UTC, Tofu Ninja wrote:
So I had an idea recently, wouldn't it be cool to have the ability to
call an executable at compile time and capture its output.

How long until D compilers are able to read mail? :-)

There's many obvious applications of this proposed feature, but I say such things should be delegated to the build process. Just run those
executables using a makefile, or whatever build system you use.

If you need compile time inputs from your D code then just run a separate build to extract them. Yes it's more work and less convenient, but I think we need to be careful with how much is added to the D
compilers. We don't want to turn them into operating systems.

Other compilers allow symbols/macros to be defined on the command line, e.g. gcc's `-D` flag; it'd be nice for DMD to define a similar mechanism
for defining enums, e.g.

---D code---
  void main() { writeln(VERSION_NUMBER); }
------------

dmd main.d -DVERSION_NUMBER=1.2

Currently I have to use my makefiles to output a whole file which defines
the various build constants.

A few minutes ago, I have a same issue. I need add some enum values as a compile option.

Now I have something like this:
version (Parser) {
        enum Application = "parser";
}
version (Report) {
        enum Application = "report";
}

But would be nice to have posibility to add same value as a compile parametr, so I could have code like this:

enum Application = __traits(getParametrValue, "MY_APPLICATION_NAME");

and compile code with some args for eg.: -VMY_APPLICATION_NAME=parser



Reply via email to