working with attributes

Walter Bright newshound2 at digitalmars.com
Fri Jan 12 07:10:34 UTC 2024


On 1/11/2024 3:05 PM, Timon Gehr wrote:
> The issue is, sometimes the piece of code that accepts lambdas is entirely 
> unopinionated about what the right attributes are, but the callback and the 
> calling code have a very strong opinion. There is no way to annotate this now 
> that makes sense, you have to duplicate the code with different attribute 
> annotations. I am not sure exactly how many overloads of `opApply` you need to 
> cater to all use cases, but I think it is more than ten.


opApply was itself a mistake, I'd prefer it to be removed, but alas. The better 
method is to use a lambda as a template alias parameter, and let the compiler 
infer the right attributes for it.


More information about the Digitalmars-d mailing list