@safe/DIP1028 explained in meme form

Q. Schroll qs.il.paperinik at gmail.com
Sat May 30 22:35:57 UTC 2020


On Thursday, 28 May 2020 at 16:59:36 UTC, Ethan wrote:
> @safe and @pure is to guarantee my programmers don't write bad 
> code.

I'm tempted to say "No, just no!" to this, but that would be 
equally wrong.
First and foremost, both are a tool to tell the compiler to error 
on code that does things that weren't intended by the 
programmers. @safe really only buys you those checks; pure gives 
you more: Optimizations (mostly theoretically) and unique 
objects: Values returned by a pure constructor (potentially any 
function, but I'm not sure) are implicitly convertible to 
immutable (if certain additional constraints are satisfied). 
Also, pure code is mostly not the source of race conditions in a 
concurrent execution.


More information about the Digitalmars-d mailing list