@trust is an encapsulation method, not an escape
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 6 13:32:46 PST 2015
On 2/6/2015 10:58 AM, David Nadlinger wrote:
> @trusted doesn't differ in meaning from @safe for API clients. Both mean that
> you can call the function from @safe code, nothing more, nothing less. I hope we
> agree on that.
That is correct. @trusted is a statement about the implementation of a function,
not its interface.
This suggests that @trusted should apply to blocks of code, not function
declarations. Pedantically, I think that would be correct. But as we've seen in
usage, this seductively makes for easy incorrect usage of @trusted.
Pragmatically, the language should make it harder to write incorrect code.
Hence, I view it as the best compromise to make @trusted also apply only at the
function level.
More information about the Digitalmars-d
mailing list