4 ms·
> Yes, and additionally there are some algorithms that are safe, but to implement require unsafe blocks. I believe kibwen's point is that every algorithm is sa
by dbaupp 9y ago
> Yes, and additionally there are some algorithms that are safe, but to implement require unsafe blocks.
I believe kibwen's point is that every algorithm is safe (when implemented correctly), since any memory safety violations inside `unsafe` blocks are incorrect. The keyword indicates the compiler can't guarantee that there isn't any, not that memory unsafety is okay. Maybe an example of the sort of thing you're thinking of would clarify the distinction you're drawing.
> I think it's obvious that there are patterns of memory access that are safe, possibly provably so, but not by the compiler at this time.
This is true of "everything": given any task X, a sufficiently smart language/compiler could allow expressing it without the risk of memory unsafety (i.e. no use of `unsafe`).