@trust is an encapsulation method, not an escape

via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 6 13:36:32 PST 2015


On Friday, 6 February 2015 at 20:13:18 UTC, Steven Schveighoffer 
wrote:
> In the proposal, @trusted code is actually considered the same 
> as @safe, but allows @system escapes.

But that can't work:

@trusted_is_safe {

   auto tmp = get_hardware_config();

   @system{
     mess_up_hardware_config();
   }

   // now this unsafe call is called in a @safe context, but is 
unsafe...
   // DMD does not catch this, so "@trusted_is_safe" is broken

   call_safe_code_that_now_is_messed_up();

   @system{
      restore_hardware_config(tmp);
   }
}





More information about the Digitalmars-d mailing list