Comment by eterps
7 years ago
What makes it unclear is exactly this 'pointery stuff'. There's nothing inherently unsafe about strongly typed pointers, but that's not the same as direct memory modification (which is obviously unsafe).
7 years ago
What makes it unclear is exactly this 'pointery stuff'. There's nothing inherently unsafe about strongly typed pointers, but that's not the same as direct memory modification (which is obviously unsafe).
Strongly typed pointers is just another name for direct memory access.
The following is perfectly typesafe:
Now if we try to do unsafe things to items, we may end up accidentally accessing memory we shouldn't.
This may or may not work, based on the runtime memory-layout of the subclass.
Basically the presence of unsafe {} means that beyond this point correctness cannot be guaranteed by the compiler. That's in fact what the keyword is for.
And that's the marker you are looking for. No need to go digging deeper into the code looking for the actual pointers themselves.