@trust is an encapsulation method, not an escape
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 6 13:19:05 PST 2015
On 2/6/2015 3:57 AM, Martin Krejcirik wrote:
> If I understand it correctly, Walter is against adding trusted blocks (trusted
> {...}) into @safe functions. But what about having safe blocks in @trusted
> functions ?
>
> int somefunc() @trusted
> {
> int a = systemfunc();
> int b;
>
> @safe {
> b = safefunc(); // calling systemfunc() not allowed;
> }
>
> return a + b;
> }
The problem is, again:
@trusted code must have a safe interface
and with code blocks, there is no interface specified to them other than
examining EVERY line of code in it.
The way interfaces are specified in D is to use functions.
More information about the Digitalmars-d
mailing list