Questions on the new __traits(parameters)

Quirin Schroll quirin.schroll at mgm-tp.com
Wed Mar 9 10:04:57 UTC 2022


In the changelog it says:
> When used inside a foreach using an overloaded `opApply`, the 
> trait yields the parameters to the delegate and not the 
> function the foreach appears within.

Why? This will rarely be wanted or be used intentionally. When a 
programmer uses `__traits(parameters)` in a `foreach` loop, it 
will for certain happen to someone not aware of this. The 
iteration implemention (`opApply` or range functions) is a detail 
one should not really have to care about on the usage side. This 
complicates the language. Morally, this is a bug. Please 
reconsider this design decision before it sticks.


More information about the Digitalmars-d mailing list