Add __traits(canCall) and __traits(resolve)

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Tue Jul 29 20:34:27 UTC 2025


On 30/07/2025 2:48 AM, Steven Schveighoffer wrote:
> On Tuesday, 29 July 2025 at 04:28:44 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> Something I've wanted for along time now, to speed up reflection is 
>> the offering to filter symbols.
>>
>> ```d
>> __traits(filterFunctionByTypes, source, Return, Parameters...)
>> ```
>>
>> Where ``source`` could be a type, alias (overload set), named import ext.
>>
>> Where ``Return`` could be ``auto`` to mean "don't care".
>>
>> But also:
>>
>> ```d
>> __traits(filterFunctionByExpression, source, args...)
>> ```
>>
>> The result of both is an alias sequence of symbols.
> 
> This is a tough one to implement, because of the auto thing. Is there a 
> reason you need to avoid passing actual types?

It would be types. Its just that auto would be consumed to mean ignore 
return since its a required argument.

> This also doesn't seem to be designed to handle templates?
> 
> -Steve

Some should work, but others may need more control to do the filtering 
as you want it to work.

The main thing is that its a transfer function, take in alias sequence, 
give an alias sequence.

It'll apply in a lot more cases if you use this form.


More information about the dip.ideas mailing list