auto attribution pros/cons

rikki cattermole rikki at cattermole.co.nz
Sun Jun 28 22:54:54 UTC 2020


I've had the same idea regarding auto inferring. A lot of us did.

Nobody has gone forward with a DIP yet, and I'm time starved atm to do 
an attempt myself.

My solution is quite simple and cheap to implement.

Start with all attributes applied if you have a body.
If you hit something that "could be" anti, you turn off that attribute.

You can do this very early on, without semantic analysis.

False positives are a good thing I think. It forces you to think about it.

On another note, something I realized was that writing @safe or @system 
yourself for anything but alias's should be a big warning sign. The only 
one you should be doing is @trusted.

The .di generator could be used to emit annotated code, not just the 
subset known as a di file. So there are a few good possibilities with 
this approach that needs testing I think.


More information about the Digitalmars-d mailing list