@trust is an encapsulation method, not an escape

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 6 10:59:16 PST 2015


On 2/6/15 12:36 PM, Atila Neves wrote:
>> I'm trying to promote suggesting '@system' blocks instead of
>> '@trusted'. '@trusted' functions, but '@system' blocks - which can
>> only go in @trusted functions (@system block in @system functions are
>> redundant). It's the same semantics, but it might win the day because
>> the intent is to isolate the @system code, while still presenting a
>> @trusted interface, as seems so important to the leadership.
>
> That might be better than using @safe inside @trusted:
>
> @trusted void myfunc() {
> //implicitly safe
> ....
> @system { //wouldn't compile otherwise.
>     auto ptr = cast(ubyte*)4;
> }
>
> //implicitly safe again
> }

BTW, this is H.S. Teoh's suggestion too, and I like it better than mine 
after much thought.

-Steve


More information about the Digitalmars-d mailing list