On Monday, August 3, 2026 1:54:48 AM Mountain Daylight Time Vindex9 via Digitalmars-d-learn wrote: > OK, thank you all. > It's actually not very convenient to think about these things all > the time. Over the years, I've gotten used to using `@system` by > default. But now it turns out that you can almost always use > `@trusted`.
You frequently can, but remember that when you mark something as @trusted, you're telling the compiler that you've verified that the code is memory-safe (whereas with @safe, the compiler has verified that). So, if you mark code with @trusted when it's not actually memory-safe, you make it so that @safe code can call code which isn't memory-safe, and the @safe code then isn't actually memory-safe. So, ideally, you'd do whatever @system stuff you need to do within a function and encapsulate the @system stuff in a way that you can mark the function as @trusted and have an API which is memory-safe, but whether you can do that or not depends on what your code is doing. - Jonathan M Davis
