Named unittests and __traits(getModules)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 20 00:14:01 UTC 2019


On 5/19/19 11:41 PM, Andrei Alexandrescu wrote:
> On 5/19/19 8:13 PM, Andre Pany wrote:
>> On Sunday, 19 May 2019 at 18:56:33 UTC, Jacob Carlborg wrote:
>>> I'm staring a new thread here on the topic of Name unittests because 
>>> the existing one is getting too long [1].
>>>
>>> [...]
>>
>> As far as i remember there was another suggestion of Andrei (in 
>> another context). By importing a module B in module A, the module B 
>> can specify coding which is executed and gets the module A as info.
>>
>> This might could also solve this issue.
> 
> Yah, it's quite a universal pattern. It can be used as "import 
> core.rtti; to add RTTI support for this module" etc.

Related: https://github.com/dlang/dmd/pull/9814. There, the idea is to 
predicate an import for each language feature or groups of features. 
Many, however, can be done as templates and realized naturally by means 
of template instantiation (e.g. a[] = b[] triggers the generation of the 
array assign support function). RTTI is different because it instructs 
the compiler to generate code a specific way without a detectable action 
in the source code. That kind of feature could be done with import + 
hook "execute this on the importing module".


More information about the Digitalmars-d mailing list