Trying to use Mir ion, its a perfect example of the failure of D's attribute system
Hipreme
msnmancini at hotmail.com
Tue Jan 24 09:55:43 UTC 2023
On Tuesday, 24 January 2023 at 07:42:32 UTC, Walter Bright wrote:
> 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
2: If everything is inferred, maybe the person doing the code
doesn't actually care if it is @safe or not. The problem on @safe
is how attributes work right now, super shitty to work now with
it (const included). Most of D code does not care with @safe. 90%
of my code could be inferred as @safe , but no, I need to
explicitly say on every function I need to define because when
creating a @safe function, I would not be able to call it.
4: It would not cause any problems with di files. Inference can
output annotation to .di files, they can be regenerated whenever
you wish to distribute.
More information about the Digitalmars-d
mailing list