Trying to use Mir ion, its a perfect example of the failure of D's attribute system

Walter Bright newshound2 at digitalmars.com
Tue Jan 24 07:42:32 UTC 2023


On 1/18/2023 8:06 PM, A moo person wrote:
> If the argument is that the library should have been designed to infer the 
> annotations, then why even have the annotations in the language at all if the 
> best practice is to infer them.

Great question! I'll start by saying generally speaking, templates should not be 
annotated and should allow inference to do its thing.

As for why one would need annotations at all:

1. the inference isn't perfect, in particular if the templates are recursive.

2. if everything is inferred, there's no way to tell code is @safe or not. This 
would be indistinguishable from having no safety checks at all.

3. use an annotation when a guarantee is desired

4. inference isn't done for conventional functions, because as mentioned before 
that would cause problems with .di files

5. to enforce a desired coding paradigm


More information about the Digitalmars-d mailing list