is(x = module) vs. __traits(isModule, x)

Steven Schveighoffer schveiguy at gmail.com
Wed Oct 7 20:01:53 UTC 2020


On 10/7/20 3:44 PM, Adam D. Ruppe wrote:
> On Wednesday, 7 October 2020 at 18:46:07 UTC, Steven Schveighoffer wrote:
>> Why both?
> 
> Why *either*?

If you want to determine if a given symbol is a module. Is there another 
way?

> The real WTF is that modules - which are not actually a child member of 
> another module - is returned in listings of __traits(allMembers).

Yeah, that's a problem we should fix. There was an almost-released fix 
which made __traits(allMembers, mod) return the full name of the 
modules, which I don't think was right either.

But aside from that, I don't see a problem with allowing someone to 
introspect whether something is a module or package.

> If you want to get imports, we should provide an alternate trait for that.

Agreed. But still I would think some mechanism to see if a symbol is a 
module is fine.

>> is(std == package) == __traits(isPackage, std);
> 
> And this is broken af right now anyway. As of the newest dmd, trying to 
> actually modules from imports slams into a brick wall.

Not sure what this was supposed to mean.

-Steve


More information about the Digitalmars-d mailing list