working with attributes

Timon Gehr timon.gehr at gmx.ch
Thu Jan 11 23:05:30 UTC 2024


On 1/11/24 23:41, Walter Bright wrote:
> 
> Any piece of code that accepts lambdas, callbacks, etc., should be very 
> clear about attribute use and how that will apply to the lambdas, etc.

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.

This is a fundamental issue with D's type system, and it is a common 
issue programming languages run into. Type theorists solve it with 
attribute polymorphism. `inout` was an attempt at that, albeit not an 
extremely successful one.


More information about the Digitalmars-d mailing list