Comment

Comment by Animats

Well, of course slices work that way. Think about what happens if you have a reference to a slice in an array and you shrank the array to 0. You've just created a dangling pointer.

In Go, you get a stable version of the old data, and the garbage collector tracks that you still have a reference to it. This is safe, but confuses some people.

In Rust, the borrow checker won't let you modify the array while you have a reference to a slice of it. So you can't do this at all.

In C++, you get a mention on the Department of Homeland Security's US-CERT site.

parent Animats 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton