Simplification of @trusted

Steven Schveighoffer schveiguy at gmail.com
Wed Jun 16 13:28:10 UTC 2021


On 6/16/21 9:22 AM, jmh530 wrote:
> On Wednesday, 16 June 2021 at 13:17:41 UTC, Steven Schveighoffer wrote:
>> [snip]
>>
>> You mean like it does now?
>> [snip]
> 
> See the code example I have above. My point isn't about @trusted per se, 
> it's about best practices for using a @trusted code block.
> 
> In my opinion, your @trusted lambda example is a bad use of @trusted 
> because you're not filling in the void initialized variable within 
> @trusted code area. The person who is trying to manually verify that 
> what is in the @trusted block is actually safe has to search for that 
> outside the block.

Of course it's bad. But this is how code is written today, because 
@trusted is too blunt an instrument (I might want just void 
initialization of that one variable, but still want other @safety checks 
throughout the rest of the function).

My point (in a slightly snarky reply, apologies) is that we don't need a 
new @trusted block feature to have the documentation identify such pitfalls.

-Steve


More information about the Digitalmars-d mailing list