Thanks! I completely forgot about import expressions! I can just as well supply a config.d with all necessary definitions!<div><br></div><div>I thing another way is to have the entire module a template and instantiate that template with necessary parameters. Although that means one has to have an additional namespace.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 24, 2012 at 2:01 AM, Peter Alexander <span dir="ltr"><<a href="mailto:peter.alexander.au@gmail.com" target="_blank">peter.alexander.au@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Friday, 23 November 2012 at 11:38:31 UTC, Gor Gyolchanyan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What's the best/standard way translating this to D?<br>
</blockquote>
<br></div>
One way is to use import expressions:<br>
<br>
import std.stdio;<br>
import std.conv;<br>
<br>
enum value = import("value").to!int();<br>
<br>
void main()<br>
{<br>
        static if (value < 100)<br>
                writeln("<100");<br>
        else<br>
                writeln(">100");<br>
}<br>
<br>
<br>
Compile using:<br>
<br>
dmd -Jpath/to/value source.d<br>
<br>
"value" should be a file containing a single integer with no new line. It will be read in at compile time and converted to a manifest integer constant, which you can use in static if statements.<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>