RFC: DIP draft for "Compiler-defined Attribute Consistency"

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Fri Jul 16 11:04:40 UTC 2021


On Friday, 16 July 2021 at 09:06:26 UTC, Alexandru Ermicioi wrote:
> ...

To add one more strong point on making them uda:

Suppose that you have a collection interface Collection(T). In 
order to make it portable and usable in safe pure or nogc code, 
the methods in collection should infer the properties of stored 
entities. This is not possible at the moment since you can't 
define these attributes based on a condition. However, if you 
make them UDA this means that you can create templates that check 
the capabilities of the stored entities and alias itself to the 
supported tuple of features, say Foo is safe but nogc, then 
instantiation of collection will become @safe Collection!Foo, 
while for nogc but unsafe Noo struct it will become @nogc 
Collection!Noo.

Regards,
Alexandru.



More information about the Digitalmars-d mailing list