3 ms·
> Additionally, lifetimes are also part of the system That "additionally" is exactly why I said "more generally". I didn't say that lifetimes were not for thr
by jnbiche 9y ago
> Additionally, lifetimes are also part of the system
That "additionally" is exactly why I said "more generally". I didn't say that lifetimes were not for thread safety. I just said that they were more generally for memory safety (I would count iterator invalidation etc as memory safety, would you not?).
- jjnoakes 9y agoSome languages throw exceptions if their iterators are invalidated, right? That seems separate from memory safety to me. Or put another way, having memory safety doesn't guarantee iterator safety.
- dbaupp 9y agoIterator invalidation can lead to memory unsafety in C++, usually due to a pointer or reference becoming dangling, but most other languages just treat it as a correctness problem: GC avoids the problem of invalidating pointers. As my parent comment hinted, some languages, like Java, try to detect (some occurrences of) these problems at runtime.