On Tuesday, 24 February 2015 at 22:49:17 UTC, w0rp wrote:
In general, @trusted means "I have proven myself that this code is actually safe, eeven though it uses unsafe features." The compiler has to be pessimistic and assume that everything which can be used unsafely will be used unsafely. @trusted, as it is used here, is used to say, "I assure you I have used this in a safe manner."

From http://dlang.org/function.html#trusted-functions :

«Trusted functions are guaranteed by the programmer to not exhibit any undefined behavior if called by a safe function.»

I take this to mean that anything that is wrapped up in @trusted should not violate memory safety when in injected into any arbitrary context marked as @safe.

I would like to see @trusted blocks, although I can see Andrei's argument of not making it easy to do intentionally.

If @trusted is meant to be used the way he is doing it in this example then there is no reason to not provide @trusted-blocks. An inlined lambda is a block...

But it provides poor encapsulation and makes for weak typing.

Reply via email to