Safety, undefined behavior, @safe, @trusted

div0 div0 at users.sourceforge.net
Thu Nov 5 13:10:17 PST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bearophile wrote:
> 
> In C# you use something like:
> 
> unsafe {
>   // lot of code
> }
> 
> I think that's a good solution. Things are meant as safe unless marked as
> Unsafe. You can mark a whole block of code as unsafe putting it into
> those brackets. D may do the same. Also single functions may have the @unsafe
attribute.
>

That's not the whole story though.

Use an unsafe block and you have to throw the appropriate compiler
switch '/unsafe' and your entire assembly can only be used if it's
'fully trusted'.

Though I forget exactly what that means, 'trust' is determined at
runtime, so e.g. code run from a web browser can't call your assembly.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK8z85T9LetA9XoXwRAjivAKCJ7At++ITg7fKmTS4ORsASzZMclACeKS1M
cK4ph1dvq3fU5OzxuJvf6w0=
=aGab
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list