January 26, 2015 How to tell an identifier is a module? | ||||
---|---|---|---|---|
| ||||
__traits(allMembers, mixin(__MODULE__)) also yields a module name like object, but then how can you find out that "object" is a module? This doesn't work: void main() { pragma(msg, is(int == int)); pragma(msg, is(object == module)); } Bye, bearophile |
January 26, 2015 Re: How to tell an identifier is a module? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 27/01/2015 2:25 a.m., bearophile wrote:
> __traits(allMembers, mixin(__MODULE__)) also yields a module name like
> object, but then how can you find out that "object" is a module?
>
> This doesn't work:
>
> void main() {
> pragma(msg, is(int == int));
> pragma(msg, is(object == module));
> }
>
> Bye,
> bearophile
static if (__traits(compiles, {mixin("import MODULENAME;");})) {
// true
} else {
// false
}
|
Copyright © 1999-2021 by the D Language Foundation