@trusted and return ref
w0rp via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 24 14:49:16 PST 2015
On Tuesday, 24 February 2015 at 22:37:58 UTC, Ola Fosheim Grøstad
wrote:
> If this is careful use of @trusted, then I don't see the point
> of having @trusted at all. What is the purpose? What is it
> meant to cover? In order for @trusted to make sense in this
> code segment ( http://dpaste.dzfl.pl/f3d854feede9 ) I would say
> that the whole class will have to be marked @trusted. Is that
> possible?
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."
I would like to see @trusted blocks, although I can see Andrei's
argument of not making it easy to do intentionally.
More information about the Digitalmars-d-learn
mailing list