safeD

Jonathan M Davis jmdavisProg at gmx.com
Sat Mar 9 12:18:20 PST 2013


On Saturday, March 09, 2013 20:47:10 Mark T wrote:
>     Thanks for the input - but where is SafeD defined? Is there a
> compiler switch?

No. It's simply code that's @safe. If you mark your functions as @safe, then 
they can only can @safe and @trusted functions and can't do any operations 
that the language considers to be @system (e.g. pointer arithmetic). So, what 
it comes down to is that you have certain safety guarantees about any code 
that's marked @safe. It's not really a separate language. It's just that you 
can only use a subset of the language within @safe code, because you can only 
use stuff that's guaranteed to be safe (though when calling @trusted code, you 
_do_ still rely on the programmer who wrote it having verified that it was 
actually safe, and they could screw that up).

Certain language constructs and core library components are not yet @safe like 
they should be, and attribute inferrence for templates still needs a lot of 
work (templated functions infer whether they're @safe, nothrow, and/or pure), 
so there's a lot of templated stuff that's perfectly safe but doesn't get 
treated that way yet. So, you're probably going to have to use @trusted more 
than would be desirable (and certainly more than you'll have to in the 
future), but on the whole, @safe itself works just fine. But it's part of the 
language, not something triggered by a compiler switch.

- Jonathan M Davis


More information about the Digitalmars-d mailing list