@system blocks and safer @trusted (ST) functions

Timon Gehr timon.gehr at gmx.ch
Mon Jul 26 03:40:55 UTC 2021


On 26.07.21 01:50, Paul Backus wrote:
> On Sunday, 25 July 2021 at 23:34:35 UTC, claptrap wrote:
>>
>> Your argument the same as saying that bar() is memory safe as written. 
>> True, but it's not bug free. The bug is just waiting for the right set 
>> of circumstances to come to life and eat your face :)
>>
>> IE. Memory safe as written != bug free
> 
> Yes; I agree completely. :)
> 
> The point of the example is to show that the proposal advanced in this 
> thread does not prevent this type of bug from occurring.

The original claim was that the new feature is a tool that allows the 
code base to be properly segregated more easily, not that you can't 
still write incorrect @trusted code. If you have to review @safe code to 
ensure memory safety of your @trusted code, your @trusted code is incorrect.

Note that the @trusted lambda idiom is _basically always_ incorrect 
@trusted code. Some people do it anyway, because it's convenient. The 
new feature allows combined convenience and correctness.


More information about the Digitalmars-d mailing list