@trust is an encapsulation method, not an escape

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 6 08:19:25 PST 2015


On Friday, 6 February 2015 at 16:11:31 UTC, Andrei Alexandrescu 
wrote:
> On 2/6/15 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 ?
>
> That would be sensible - perhaps the best step forward 
> following this long discussion. -- Andrei

It feels inelegant, but it might be the best way out of a bad 
situation.

I can instantly see this happening:

void foo() @trusted
{
     @safe
     {
         //loads of code
     }

     //a few lines of system code, only safe due to context in the 
@safe blocks

     @safe
     {
         \\loads of code
     }
}

Is that what we want? I can't see why not, but it feels off 
somehow... Effectively you've got @trusted blocks in an @trusted 
function, just inverted.


More information about the Digitalmars-d mailing list