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

Steven Schveighoffer schveiguy at gmail.com
Thu Oct 8 14:04:13 UTC 2020


On 10/8/20 4:12 AM, Kagamin wrote:
> On Wednesday, 7 October 2020 at 18:46:07 UTC, Steven Schveighoffer wrote:
>> Why both? The first thing that struck me is that, std.stdio is NOT a 
>> type. `is` specifically says it works with types. So that seems out of 
>> place (indeed the documentation does not mention anything special 
>> about this).
> 
> Guess, it's a bit of pl theory, I saw mentioned somewhere that modules 
> count as types. Not sure about packages though.

It's literally special cased in the code:

https://github.com/dlang/dmd/blob/013eccaf113e6f23784c615d3ec66434c3629197/src/dmd/expressionsem.d#L5418

-Steve


More information about the Digitalmars-d mailing list