Safety, undefined behavior, @safe, @trusted

Walter Bright newshound1 at digitalmars.com
Thu Nov 5 12:12:09 PST 2009


Steven Schveighoffer wrote:
> If unsafe means you cannot pass pointers to local variables, then half 
> of tango (and other performance oriented libs which use stack allocation 
> as much as possible) will fail to compile.
>
> My vote is for unsafe as the default.  It's the least intrusive option, 
> to ensure that current projects still compile.  Then let the project 
> authors ensure their projects are safe one module/function at a time.

I agree. Also, dealing with safeness is something that comes later on as 
a project scales to a larger size. As such, it's more of a nuisance on a 
small program than a help.

> Also keep in mind that @safe annotations for a mostly safe project will 
> be once at the top of each module.  They won't be "everywhere".

Right. Adding:

    @safe:

at the top will do it.



More information about the Digitalmars-d mailing list