is `allMembers` useless for modules?

Neia Neutuladh neia at ikeran.org
Mon Jan 14 18:47:54 UTC 2019


On Mon, 14 Jan 2019 14:22:56 +0000, FeepingCreature wrote:
> On Monday, 14 January 2019 at 14:06:02 UTC, Atila Neves wrote:
>>> It lists imported packages and modules, even though there's no way to
>>> detect if a symbol is a module
>>
>> Sure there is: `enum isModule(string moduleName) = is(typeof(mixin(`{
>> import `, moduleName, `; }`)))`
>>
>>
> Right, to restate, there's no non-brute-force way. This should really be
> a trait; if the compiler offers you a symbol, it should also give you a
> clean way to determine the nature of that symbol.

I would have expected this to work:

    assert(is(std == package));
    assert(is(std.stdio == module));

Alas.

I didn't think it would be that difficult to add, except the compiler's 
hard-coded to consider the left-hand side a type. I don't see how to treat 
something as a reference to either a package or a module or a type in that 
code. I think the solution is to defer symbol lookup until IsExp semantic.


More information about the Digitalmars-d mailing list