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

Nick Treleaven nick at geany.org
Sun Oct 11 09:08:30 UTC 2020


On Thursday, 8 October 2020 at 12:43:48 UTC, RazvanN wrote:
> Therefore, in this case I suggest that we deprecate `is(S == 
> module)`

We could just ghost it. Deprecation would be fine except people 
tend to remove deprecated things after a while, breaking legacy 
code.

> (since a module is not a type anyway)

Absolutely, it is very jarring if a conceptual feature is broken 
like this.

>> is ( Type == TypeSpecialization )

A module/package clearly isn't a type, so either the docs are 
wrong or is(mod == module) is wrong. All the other keywords are 
types, as the design intended:

>> If TypeSpecialization is one of struct union class interface 
>> enum function delegate const immutable shared module package 
>> then the condition is satisfied if Type is one of those.

> and implement an isModule template in std.traits.

Don't template wrappers create bloat when instantiated? For a 
module name, probably not important. But the principle of 
wrapping every __traits might not scale well.


More information about the Digitalmars-d mailing list