alias A;//now compiles as a no op
alias A;
void foo()=>A;//fails A is undefined
#! dmd -A=3.14 -run
alias A;
void foo()=>A;//compiles, returns 3.14;
struct myint{int i;}
import test(A:myint(6.28));
unittest{
foo.writeln;//myint(6.28);
}
Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 22 Undefined aliases as compile time flags and import arguments | ||||
---|---|---|---|---|
| ||||
|
April 23 Re: Undefined aliases as compile time flags and import arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to monkyyy | On Tuesday, 22 April 2025 at 16:00:50 UTC, monkyyy wrote: >
I’m not sure how well this approach would scale with larger projects. In particular it seems to bypass/ignore the module system provided by the language. |
April 23 Re: Undefined aliases as compile time flags and import arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to monkyyy | On Tuesday, 22 April 2025 at 16:00:50 UTC, monkyyy wrote: >
Presumably the above is
That seems to have the effect of the Just to mention, this was not easy to work was going on in your example (regardless of whether the module is a template or not). There is a style convention of types ( |
April 23 Re: Undefined aliases as compile time flags and import arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to monkyyy | On Tuesday, 22 April 2025 at 16:00:50 UTC, monkyyy wrote: >
Something like this has been proposed before, and rejected to prevent facilitating overly complex build processes: https://github.com/dlang/dmd/pull/15257#issuecomment-1585835222 |
April 23 Re: Undefined aliases as compile time flags and import arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Elias Batek (0xEAB) | On Wednesday, 23 April 2025 at 00:28:07 UTC, Elias Batek (0xEAB) wrote: >On Tuesday, 22 April 2025 at 16:00:50 UTC, monkyyy wrote: >
I’m not sure how well this approach would scale with larger projects. In particular it seems to bypass/ignore the module system provided by the language. It directly engages with the module system |