<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 25 Aug 2024 at 21:31, Paolo Invernizzi via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sunday, 25 August 2024 at 10:32:31 UTC, Manu wrote:<br>
> On Sun, 25 Aug 2024 at 19:56, Paolo Invernizzi via <br>
> Digitalmars-d < <a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>> wrote:<br>
><br>
>> On Saturday, 24 August 2024 at 17:43:38 UTC, Manu wrote:<br>
>> > On Sun, 25 Aug 2024 at 03:31, Richard (Rikki) Andrew <br>
>> > Cattermole via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>> <br>
>> > wrote:<br>
>> ><br>
>> >> On 25/08/2024 5:10 AM, Manu wrote:<br>
>> >> > [...]<br>
>> >><br>
>> >> I've been considering something along these lines.<br>
>> >><br>
>> >> Specifically, ``@trusted`` does not mean the entire body <br>
>> >> shouldn't be verified. It just means that you are going to <br>
>> >> do something naughty that needs looking at.<br>
>> >><br>
>> >> So you need annotated scopes inside of it, to do the <br>
>> >> naughty thing.<br>
>><br>
>> Just wrote a trusted function and call it: that's the sane way <br>
>> to do it and respect code reviewer hard job.<br>
><br>
><br>
> ...so, because I'm going to make one single unsafe function <br>
> call inside of some function, I should eject all other related <br>
> or unrelated safety checks for the entire surrounding context?<br>
<br>
No, you should isolate the unsafe part of code into a function, <br>
explain why it’s unsafe, the intent of the code, the expected <br>
parameter values and the expected returns, so that reviewer can <br>
check that the interface is really memory safe.<br>
<br>
Then call this extremely simple function from the rest of safe <br>
code safe code.<br>
<br></blockquote><div> </div><div>
<div>So, this then:</div><div><br></div><div>extern(C) int myUnsafeFunction(int x, int y);</div><div><br></div><div>@trusted int myPointlessWrapper(int x, int y)</div><div>{</div><div>  return 
myUnsafeFunction

(x, y);<br></div><div>}<br></div><div><br></div><div>@safe mySuperSafeFunction(...)</div><div>{</div><div>   //... lots of code</div><div><br></div><div>  int r = 
myPointlessWrapper(arg1, arg2);<br></div><div><br></div><div>  //... lots of code<br></div><div>}<br></div><div><br></div><div>Brilliant.<br></div></div></div></div>