www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - externally imposed conditional compilation

reply Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d04088d2355090904cf28050a
Content-Type: text/plain; charset=UTF-8

Hi, D community.

I have C code (*cough* WinAPI *cough*) like:

#if FOOBAR == 1
#define SOMETHING
#elif FOOBAR > 2
#define SOMETHING
#elif FOOBAR < 5
#define SOMETHING
#endif

Which I want to translate to D.

Here are the problems I have:
1. I can't use versions because:
    1.1. The identifier version won't work because the set of values for
FOOBAR is unknown, thus cannot be enumerated as different version
identifiers.
    1.2. The number version won't work because there are tons of other
things like FOOBAR and they can't all use the version number.
2. I can't use static if because:
    2.1. I can't define FOOBAR from outside of the package this code will
be in.
    2.2. I can't include the definition of FOOBAR into the package (like
config.d) and expect it to be changed as necessary, because the package
encapsulation will be broken.

What's the best/standard way translating this to D?

-- 
Bye,
Gor Gyolchanyan.

--f46d04088d2355090904cf28050a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi, D community.<div><br></div><div>I have C code (*cough* WinAPI *cough*) =
like:</div><div><br></div><div>#if FOOBAR =3D=3D 1</div><div>#define SOMETH=
ING</div><div>#elif FOOBAR &gt; 2</div><div>#define SOMETHING</div><div>#el=
if FOOBAR &lt; 5</div>
<div>#define SOMETHING</div><div>#endif<br clear=3D"all"><div><br></div><di=
v>Which I want to translate to D.</div><div><br></div><div>Here are the pro=
blems I have:</div><div>1. I can&#39;t use versions because:</div><div>=C2=
=A0 =C2=A0 1.1. The identifier version won&#39;t work because the set of va=
lues for FOOBAR is unknown, thus cannot be enumerated as different version =
identifiers.</div>
<div>=C2=A0 =C2=A0 1.2. The number version won&#39;t work because there are=
 tons of other things like FOOBAR and they can&#39;t all use the version nu=
mber.</div><div>2. I can&#39;t use static if because:</div><div>=C2=A0 =C2=
=A0 2.1. I can&#39;t define FOOBAR from outside of the package this code wi=
ll be in.</div>
<div>=C2=A0 =C2=A0 2.2. I can&#39;t include the definition of FOOBAR into t=
he package (like config.d) and expect it to be changed as necessary, becaus=
e the package encapsulation will be broken.</div><div><br></div><div><div>W=
hat&#39;s the best/standard way translating this to D?</div>
</div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>

--f46d04088d2355090904cf28050a--
Nov 23 2012
next sibling parent "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Friday, 23 November 2012 at 11:38:31 UTC, Gor Gyolchanyan 
wrote:
 What's the best/standard way translating this to D?

One way is to use import expressions: import std.stdio; import std.conv; enum value = import("value").to!int(); void main() { static if (value < 100) writeln("<100"); else writeln(">100"); } Compile using: dmd -Jpath/to/value source.d "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.
Nov 23 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--485b390f7a16c0365304cf30fd38
Content-Type: text/plain; charset=UTF-8

Thanks! I completely forgot about import expressions! I can just as well
supply a config.d with all necessary definitions!

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.


On Sat, Nov 24, 2012 at 2:01 AM, Peter Alexander <
peter.alexander.au gmail.com> wrote:

 On Friday, 23 November 2012 at 11:38:31 UTC, Gor Gyolchanyan wrote:

 What's the best/standard way translating this to D?

One way is to use import expressions: import std.stdio; import std.conv; enum value = import("value").to!int(); void main() { static if (value < 100) writeln("<100"); else writeln(">100"); } Compile using: dmd -Jpath/to/value source.d "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.

-- Bye, Gor Gyolchanyan. --485b390f7a16c0365304cf30fd38 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks! I completely forgot about import expressions! I can just as well su= pply 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 te= mplate with necessary parameters. Although that means one has to have an ad= ditional namespace.</div> <div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Sat, Nov 2= 4, 2012 at 2:01 AM, Peter Alexander <span dir=3D"ltr">&lt;<a href=3D"mailto= :peter.alexander.au gmail.com" target=3D"_blank">peter.alexander.au gmail.c= om</a>&gt;</span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div class=3D"im">On Friday, 23 November 201= 2 at 11:38:31 UTC, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> What&#39;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 =3D import(&quot;value&quot;).to!int();<br> <br> void main()<br> {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 static if (value &lt; 100)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 writeln(&quot;&lt;1= 00&quot;);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 else<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 writeln(&quot;&gt;1= 00&quot;);<br> }<br> <br> <br> Compile using:<br> <br> dmd -Jpath/to/value source.d<br> <br> &quot;value&quot; 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 intege= r constant, which you can use in static if statements.<br> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor = Gyolchanyan.<br> </div> --485b390f7a16c0365304cf30fd38--
Nov 23 2012
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 23 November 2012 at 22:20:39 UTC, Gor Gyolchanyan 
wrote:
 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.

Mixin the template into the module scope? http://dpaste.dzfl.pl/b140509f
Nov 23 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--047d7b66fa1b73e3f204cf37599a
Content-Type: text/plain; charset=UTF-8

In case of WinAPI itself, which takes a dozen of preprocessor definitions,
would you like a WinAPI binding, where you need to mix in the WinAPI?


On Sat, Nov 24, 2012 at 5:12 AM, Vladimir Panteleev <
vladimir thecybershadow.net> wrote:

 On Friday, 23 November 2012 at 22:20:39 UTC, Gor Gyolchanyan wrote:

 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.

Mixin the template into the module scope? http://dpaste.dzfl.pl/b140509f

-- Bye, Gor Gyolchanyan. --047d7b66fa1b73e3f204cf37599a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In case of WinAPI itself, which takes a dozen of preprocessor definitions, = would you like a WinAPI binding, where you need to mix in the WinAPI?<div c= lass=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Sat, Nov 24, 201= 2 at 5:12 AM, Vladimir Panteleev <span dir=3D"ltr">&lt;<a href=3D"mailto:vl= adimir thecybershadow.net" target=3D"_blank">vladimir thecybershadow.net</a=
&gt;</span> wrote:<br>

x #ccc solid;padding-left:1ex"><div class=3D"im">On Friday, 23 November 201= 2 at 22:20:39 UTC, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> I thing another way is to have the entire module a template and instantiate= <br> that template with necessary parameters. Although that means one has to<br> have an additional namespace.<br> </blockquote> <br></div> Mixin the template into the module scope?<br> <a href=3D"http://dpaste.dzfl.pl/b140509f" target=3D"_blank">http://dpaste.= dzfl.pl/b140509f</a><br> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor = Gyolchanyan.<br> </div> --047d7b66fa1b73e3f204cf37599a--
Nov 23 2012
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Saturday, 24 November 2012 at 05:55:49 UTC, Gor Gyolchanyan 
wrote:
 In case of WinAPI itself, which takes a dozen of preprocessor 
 definitions,
 would you like a WinAPI binding, where you need to mix in the 
 WinAPI?

I believe the bindings on dsource use a sensible solution. It is similar to what is used in e.g. Pascal, the preprocessor of which doesn't support define values or comparisons (only IFDEF).
Nov 23 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--047d7b603bb043c38c04cf38059a
Content-Type: text/plain; charset=UTF-8

which is: take a version flag, make a enum out of it and compare it as you
want. right?


On Sat, Nov 24, 2012 at 10:39 AM, Vladimir Panteleev <
vladimir thecybershadow.net> wrote:

 On Saturday, 24 November 2012 at 05:55:49 UTC, Gor Gyolchanyan wrote:

 In case of WinAPI itself, which takes a dozen of preprocessor definitions,
 would you like a WinAPI binding, where you need to mix in the WinAPI?

I believe the bindings on dsource use a sensible solution. It is similar to what is used in e.g. Pascal, the preprocessor of which doesn't support define values or comparisons (only IFDEF).

-- Bye, Gor Gyolchanyan. --047d7b603bb043c38c04cf38059a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable which is: take a version flag, make a enum out of it and compare it as you = want. right?<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">O= n Sat, Nov 24, 2012 at 10:39 AM, Vladimir Panteleev <span dir=3D"ltr">&lt;<= a href=3D"mailto:vladimir thecybershadow.net" target=3D"_blank">vladimir th= ecybershadow.net</a>&gt;</span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div class=3D"im">On Saturday, 24 November 2= 012 at 05:55:49 UTC, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> In case of WinAPI itself, which takes a dozen of preprocessor definitions,<= br> would you like a WinAPI binding, where you need to mix in the WinAPI?<br> </blockquote> <br></div> I believe the bindings on dsource use a sensible solution. It is similar to= what is used in e.g. Pascal, the preprocessor of which doesn&#39;t support= define values or comparisons (only IFDEF).<br> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor = Gyolchanyan.<br> </div> --047d7b603bb043c38c04cf38059a--
Nov 23 2012
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-11-23 12:38, Gor Gyolchanyan wrote:

 2. I can't use static if because:
      2.1. I can't define FOOBAR from outside of the package this code
 will be in.
      2.2. I can't include the definition of FOOBAR into the package
 (like config.d) and expect it to be changed as necessary, because the
 package encapsulation will be broken.

What about using version identifiers to set constants and the use static-if? Something like this: https://github.com/jacob-carlborg/dvm/blob/d1/dvm/util/Version.d -- /Jacob Carlborg
Nov 25 2012
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-11-27 08:22, Gor Gyolchanyan wrote:
 Nice idea, especially with the template to make things easier. Still it
 looks ugly. Version identifiers and numbers (as well as debug
 identifiers and numbers) serve a very good purpose (parametrizing
 modules), but they're vastly incomplete. There's so much useful stuff
 that could be done if module could have access to data of user defined
 types. I think this is very close to the idea of UDAs. If UDAs become
 mutable (which I think would be the most important feature of UDAs),
 then the module declaration could also get mutable UDAs, which would
 solve all problems. Don't you think? And version identifiers can be used
 as described in Version.d, except they'll change the module UDAs instead
 of defining a manifest constant.

Do you have any example of how you would like this to look like? -- /Jacob Carlborg
Nov 26 2012
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-11-27 08:25, Gor Gyolchanyan wrote:
 I'd go one step forward to also allow UDAs on packages. This will be
 very useful for conditionally compiling entire libraries, instead of
 manually setting the same UDAs for every module in the package.

How would that work? You cannot declare a package, only modules. -- /Jacob Carlborg
Nov 26 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0407166d6dbb1704cf74ea59
Content-Type: text/plain; charset=UTF-8

Nice idea, especially with the template to make things easier. Still it
looks ugly. Version identifiers and numbers (as well as debug identifiers
and numbers) serve a very good purpose (parametrizing modules), but they're
vastly incomplete. There's so much useful stuff that could be done if
module could have access to data of user defined types. I think this is
very close to the idea of UDAs. If UDAs become mutable (which I think would
be the most important feature of UDAs), then the module declaration could
also get mutable UDAs, which would solve all problems. Don't you think? And
version identifiers can be used as described in Version.d, except they'll
change the module UDAs instead of defining a manifest constant.


On Sun, Nov 25, 2012 at 3:56 PM, Jacob Carlborg <doob me.com> wrote:

 On 2012-11-23 12:38, Gor Gyolchanyan wrote:

  2. I can't use static if because:
      2.1. I can't define FOOBAR from outside of the package this code
 will be in.
      2.2. I can't include the definition of FOOBAR into the package
 (like config.d) and expect it to be changed as necessary, because the
 package encapsulation will be broken.

What about using version identifiers to set constants and the use static-if? Something like this: https://github.com/jacob-**carlborg/dvm/blob/d1/dvm/util/**Version.d<https://github.com/jacob-carlborg/dvm/blob/d1/dvm/util/Version.d> -- /Jacob Carlborg

-- Bye, Gor Gyolchanyan. --f46d0407166d6dbb1704cf74ea59 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Nice idea, especially with the template to make things easier. Still it loo= ks ugly. Version identifiers and numbers (as well as debug identifiers and = numbers) serve a very good purpose (parametrizing modules), but they&#39;re= vastly incomplete. There&#39;s so much useful stuff that could be done if = module could have access to data of user defined types. I think this is ver= y close to the idea of UDAs. If UDAs become mutable (which I think would be= the most important feature of UDAs), then the module declaration could als= o get mutable UDAs, which would solve all problems. Don&#39;t you think? An= d version identifiers can be used as described in Version.d, except they&#3= 9;ll change the module UDAs instead of defining a manifest constant.<div cl= ass=3D"gmail_extra"> <br><br><div class=3D"gmail_quote">On Sun, Nov 25, 2012 at 3:56 PM, Jacob C= arlborg <span dir=3D"ltr">&lt;<a href=3D"mailto:doob me.com" target=3D"_bla= nk">doob me.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div class=3D"im">On 2012-11-23 12:38, Gor Gyolchanyan wrote:<br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> 2. I can&#39;t use static if because:<br> =C2=A0 =C2=A0 =C2=A02.1. I can&#39;t define FOOBAR from outside of the pack= age this code<br> will be in.<br> =C2=A0 =C2=A0 =C2=A02.2. I can&#39;t include the definition of FOOBAR into = the package<br> (like config.d) and expect it to be changed as necessary, because the<br> package encapsulation will be broken.<br> </blockquote> <br></div> What about using version identifiers to set constants and the use static-if= ? Something like this:<br> <br> <a href=3D"https://github.com/jacob-carlborg/dvm/blob/d1/dvm/util/Version.d= " target=3D"_blank">https://github.com/jacob-<u></u>carlborg/dvm/blob/d1/dv= m/util/<u></u>Version.d</a><span class=3D"HOEnZb"><font color=3D"#888888"><= br> <br> -- <br> /Jacob Carlborg<br> </font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b= r>Bye,<br>Gor Gyolchanyan.<br> </div> --f46d0407166d6dbb1704cf74ea59--
Nov 26 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--f46d0401240bd4953804cf74f35e
Content-Type: text/plain; charset=UTF-8

I'd go one step forward to also allow UDAs on packages. This will be very
useful for conditionally compiling entire libraries, instead of manually
setting the same UDAs for every module in the package.


On Tue, Nov 27, 2012 at 11:22 AM, Gor Gyolchanyan <
gor.f.gyolchanyan gmail.com> wrote:

 Nice idea, especially with the template to make things easier. Still it
 looks ugly. Version identifiers and numbers (as well as debug identifiers
 and numbers) serve a very good purpose (parametrizing modules), but they're
 vastly incomplete. There's so much useful stuff that could be done if
 module could have access to data of user defined types. I think this is
 very close to the idea of UDAs. If UDAs become mutable (which I think would
 be the most important feature of UDAs), then the module declaration could
 also get mutable UDAs, which would solve all problems. Don't you think? And
 version identifiers can be used as described in Version.d, except they'll
 change the module UDAs instead of defining a manifest constant.


 On Sun, Nov 25, 2012 at 3:56 PM, Jacob Carlborg <doob me.com> wrote:

 On 2012-11-23 12:38, Gor Gyolchanyan wrote:

  2. I can't use static if because:
      2.1. I can't define FOOBAR from outside of the package this code
 will be in.
      2.2. I can't include the definition of FOOBAR into the package
 (like config.d) and expect it to be changed as necessary, because the
 package encapsulation will be broken.

What about using version identifiers to set constants and the use static-if? Something like this: https://github.com/jacob-**carlborg/dvm/blob/d1/dvm/util/**Version.d<https://github.com/jacob-carlborg/dvm/blob/d1/dvm/util/Version.d> -- /Jacob Carlborg

-- Bye, Gor Gyolchanyan.

-- Bye, Gor Gyolchanyan. --f46d0401240bd4953804cf74f35e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I&#39;d go one step forward to also allow UDAs on packages. This will be ve= ry useful for conditionally compiling entire libraries, instead of manually= setting the same UDAs for every module in the package.<div class=3D"gmail_= extra"> <br><br><div class=3D"gmail_quote">On Tue, Nov 27, 2012 at 11:22 AM, Gor Gy= olchanyan <span dir=3D"ltr">&lt;<a href=3D"mailto:gor.f.gyolchanyan gmail.c= om" target=3D"_blank">gor.f.gyolchanyan gmail.com</a>&gt;</span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Nice idea, especially with the template to make things easier. Still it loo= ks ugly. Version identifiers and numbers (as well as debug identifiers and = numbers) serve a very good purpose (parametrizing modules), but they&#39;re= vastly incomplete. There&#39;s so much useful stuff that could be done if = module could have access to data of user defined types. I think this is ver= y close to the idea of UDAs. If UDAs become mutable (which I think would be= the most important feature of UDAs), then the module declaration could als= o get mutable UDAs, which would solve all problems. Don&#39;t you think? An= d version identifiers can be used as described in Version.d, except they&#3= 9;ll change the module UDAs instead of defining a manifest constant.<div cl= ass=3D"gmail_extra"> <div><div class=3D"h5"> <br><br><div class=3D"gmail_quote">On Sun, Nov 25, 2012 at 3:56 PM, Jacob C= arlborg <span dir=3D"ltr">&lt;<a href=3D"mailto:doob me.com" target=3D"_bla= nk">doob me.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div>On 2012-11-23 12:38, Gor Gyolchanyan wrote:<br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> 2. I can&#39;t use static if because:<br> =C2=A0 =C2=A0 =C2=A02.1. I can&#39;t define FOOBAR from outside of the pack= age this code<br> will be in.<br> =C2=A0 =C2=A0 =C2=A02.2. I can&#39;t include the definition of FOOBAR into = the package<br> (like config.d) and expect it to be changed as necessary, because the<br> package encapsulation will be broken.<br> </blockquote> <br></div> What about using version identifiers to set constants and the use static-if= ? Something like this:<br> <br> <a href=3D"https://github.com/jacob-carlborg/dvm/blob/d1/dvm/util/Version.d= " target=3D"_blank">https://github.com/jacob-<u></u>carlborg/dvm/blob/d1/dv= m/util/<u></u>Version.d</a><span><font color=3D"#888888"><br> <br> -- <br> /Jacob Carlborg<br> </font></span></blockquote></div><br><br clear=3D"all"><div><br></div></div=
</div><span class=3D"HOEnZb"><font color=3D"#888888">-- <br>Bye,<br>Gor Gy=

</font></span></div> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Bye,<br>Gor = Gyolchanyan.<br> </div> --f46d0401240bd4953804cf74f35e--
Nov 26 2012
prev sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
--485b390f7a1647eec404cf755827
Content-Type: text/plain; charset=UTF-8

There's a tiny, but extremely useful enhancement request, that resides in
bugzilla for a long time now. It proposes the possibility to have modules
named "package", in which case they're imported using their package name
alone:

mylib
    core.d
    aux.d
    package.d

// main.d:
    import mylib.core;
    import mylib.aux;
    import mylib;

In this case adding UDAs to packages essentially means adding UDAs to the
"package" module.
And adding UDAs to any modules would look like this:

[MyUda] module mylib.core;

Since the module-level import statements affect the entire module, the
later imports would be enough to make the MyUda type visible at the top.


On Tue, Nov 27, 2012 at 11:42 AM, Jacob Carlborg <doob me.com> wrote:

 On 2012-11-27 08:25, Gor Gyolchanyan wrote:

 I'd go one step forward to also allow UDAs on packages. This will be
 very useful for conditionally compiling entire libraries, instead of
 manually setting the same UDAs for every module in the package.

How would that work? You cannot declare a package, only modules. -- /Jacob Carlborg

-- Bye, Gor Gyolchanyan. --485b390f7a1647eec404cf755827 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable There&#39;s a tiny, but extremely useful enhancement request, that resides = in bugzilla for a long time now. It proposes the possibility to have module= s named &quot;package&quot;, in which case they&#39;re imported using their= package name alone:<div> <br></div><div>mylib</div><div>=C2=A0 =C2=A0 core.d</div><div>=C2=A0 =C2=A0= aux.d</div><div>=C2=A0 =C2=A0 package.d</div><div><br></div><div>// main.d= :</div><div>=C2=A0 =C2=A0 import mylib.core;</div><div>=C2=A0 =C2=A0 import= mylib.aux;</div><div>=C2=A0 =C2=A0 import mylib;</div><div> <br></div><div>In this case adding UDAs to packages essentially means addin= g UDAs to the &quot;package&quot; module.</div><div>And adding UDAs to any = modules would look like this:</div><div><br></div><div>[MyUda] module mylib= .core;</div> <div><br></div><div>Since the module-level import statements affect the ent= ire module, the later imports would be enough to make the MyUda type visibl= e at the top.</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_q= uote"> On Tue, Nov 27, 2012 at 11:42 AM, Jacob Carlborg <span dir=3D"ltr">&lt;<a h= ref=3D"mailto:doob me.com" target=3D"_blank">doob me.com</a>&gt;</span> wro= te:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-= left:1px #ccc solid;padding-left:1ex"> <div class=3D"im">On 2012-11-27 08:25, Gor Gyolchanyan wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> I&#39;d go one step forward to also allow UDAs on packages. This will be<br=

manually setting the same UDAs for every module in the package.<br> </blockquote> <br></div> How would that work? You cannot declare a package, only modules.<span class= =3D"HOEnZb"><font color=3D"#888888"><br> <br> -- <br> /Jacob Carlborg<br> </font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b= r>Bye,<br>Gor Gyolchanyan.<br> </div> --485b390f7a1647eec404cf755827--
Nov 26 2012