daii - allocator-friendly closures and raii

Steven Schveighoffer via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Jun 23 14:24:26 PDT 2017


On 6/23/17 4:24 PM, Boris-Barboris wrote:
> On Friday, 23 June 2017 at 20:13:07 UTC, ag0aep6g wrote:
>> You've got bad `@trusted`s:
> 
> Ty, I misunderstood the concept. I guess in a code like this it's mostly 
> @system anyways, too many indirections to control safety level. I'm 
> probably gonna remove most of the attributes.

The best advice is to leave @safe and @trusted and @system out of any 
templates. @safe will be inferred if everything is indeed safe. To prove 
that it's actually @safe, use a @safe unittest.

For places where things are safe, but the compiler can't prove it, then 
you pull out the @trusted attribute. But be very very careful -- as 
ag0aep6g says, there are often many hidden calls that can be @system, 
and in those cases you have just broken the guarantee. Only use @trusted 
where you know everything about every type that is used inside the call.

-Steve


More information about the Digitalmars-d-announce mailing list