how much "real-life" code can be marked @safe ?

someone someone at somewhere.com
Fri Jul 2 00:26:52 UTC 2021


... just wondering:

I am writing pretty trivial code, nothing out of the ordinary, 
and attempted to check how much of it could be marked safe ...

- Lots of tiny common library functions are pretty easy

- Getter/Setter properties are easy too

- almost all this() constructors are a no-go providing you do 
something in-between with the parameters until you assign them 
back to the target variables; eg: you have a char parameter (that 
you need to do something with it) that needs to be assigned to a 
class/structure string member variable and then it needs a cast 
... but no castings are allowed with @safe

But when you start attempting to declare @safe chunks of code 
that actually DO things ... well, it seems end-of-the-story.

Declaring @safe void() main() {...} as I was advised in some 
previous post (to avoid declaring @safe everywhere) is almost 
impossible unless you are doing the hello world app.

I would love to hear how you, I mean the community, approach code 
safeness ?


More information about the Digitalmars-d-learn mailing list