Help, what is the code mean?

data pulverizer data.pulverizer at gmail.com
Mon Apr 27 15:28:53 UTC 2020


On Monday, 27 April 2020 at 13:36:25 UTC, Adam D. Ruppe wrote:
> On Monday, 27 April 2020 at 13:29:08 UTC, lilijreey wrote:
>> Hi:
>>    In dlang core.thread.osthread has below code, the 654 line 
>> code i can understand why write () first, and {m_fn = fn;}()  
>> do what?
>
> The stdlib uses that pattern from time to time to indicate an 
> unsafe block in an otherwise safe function.
>
> Specifically it is a little trusted inline function being 
> immediately called.
>
> It is something that should be avoided whenever you can.

I'm probably not the first person to say this but. Isn't @trusted 
an odd label to give unsafe functions and open to abuse by 
unscrupulous programmers? It almost says "nothing to see, this 
here piece of code is a-ok". Shouldn't it be explicitly labelled 
as @unsafe?


More information about the Digitalmars-d-learn mailing list