Comment by dnautics
19 hours ago
so yes it is possible to detect those patterns and ban them as unsafe, and have a"safety checked alternative. clr does this currently:
https://github.com/ityonemo/clr#safety-oriented-architecture
19 hours ago
so yes it is possible to detect those patterns and ban them as unsafe, and have a"safety checked alternative. clr does this currently:
https://github.com/ityonemo/clr#safety-oriented-architecture
It's possible to detect and ban the version of the problematic pattern that I made as short and simple as possible to illustrate the point, sure.
I'm general though, I don't believe it is practical to do so. Not without every library being designed with the checker in mind and annotated to more precisely describe their APIs. Which is why I'm not surprised to see the limitations.md that seems to exclude all the hard cases (aliasing, pointers used as first class values, cross function analysis): https://github.com/ityonemo/clr/blob/main/LIMITATIONS.md#mem...
Obviously if you rewrite the zig world to obey rust like rules and include rust like annotations you can implement a rust like borrow checker, but I don't think that it would still be meaningfully zig. It might be an interesting language worth exploring.
i dont understand the downvotes here. the point of any safety checker is to flag and ban potentially unsafe code, and force the author to rewrite with existing language patterns that guarantee the desired safety parameters.
in this case, zig has a first class nullable syntax that the checker can use ti guarantee correctness for, so a checker can deterministically sidestep this turing completeness issue, by squeezing indeterminate code into the knowably safer language idiom.