@system blocks and safer @trusted (ST) functions

claptrap clap at trap.com
Sun Jul 25 22:32:57 UTC 2021


On Sunday, 25 July 2021 at 21:32:00 UTC, Paul Backus wrote:
>
> The underlying problem in both cases is that the memory safety 
> of the manually-checked code (`@system` block/`@trusted` 
> lambda) depends on details of the automatically-checked code 
> that are not robust against change.

I think the problem is you're conflating memory safety and 
validity. When you slap @safe on favouriteNumber you're not 
telling the world that it will always return a valid result, 
you're telling the world that it wont corrupt memory.

IE.. @safe doesnt mean you can blindly use the result of a 
function.

EG.. if you have a @safe version of getchar(), would you blindly 
use the result of that?


More information about the Digitalmars-d mailing list