working with attributes

Timon Gehr timon.gehr at gmx.ch
Fri Jan 12 14:54:15 UTC 2024


On 1/12/24 08:10, Walter Bright wrote:
> 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.

Well, I have wished for an `opApply` with template alias sometimes, but 
this does not always work. E.g., `opApply` may be a virtual function 
(which comprises quite a lot of my own `opApply` use cases). Anyway, 
`opApply` is just one example that happens to be particularly familiar 
to many D programmers. Do you think virtual methods and runtime 
delegates were a mistake in general?


More information about the Digitalmars-d mailing list