@trusted attribute should be replaced with @trusted blocks

IGotD- nise at nise.com
Thu Jan 16 00:09:23 UTC 2020

On Wednesday, 15 January 2020 at 23:46:11 UTC, ag0aep6g wrote:
> You're saying that it is useful for me as a user of Phobos when 
> I see that, for example, std.stdio.File.open is @trusted [1], 
> right?

Speaking of libraries, as you can see many calls will go the C 
library which is of course is unsafe code. The only way I can see 
it is that @safe code should be able to call unsafe code by 
default, for convenience.

Now there is a possibility that the programmer wants that the 
code shall not call any unsafe code what so ever. Then I think 
that a function attribute should be added that tells that the 
code is not allowed to call any unsafe code down the line. This 
is better because.

1. It is a restriction set by the programmer and not some 
arbitrary promise from a third party.
2. It is absolute. The compiler can check this, either it hits 
unsafe or it doesn't. It is either true or false and it cannot be 

More information about the Digitalmars-d mailing list