Please don't under-quote, thanks.
Pointers are perfectly fine as long as there is no pointer arithmetic.
Wrong. Merely holding a pointer (i.e. a physical address) is unsafe already.
Non-deep serialization, or any other "preservation" of such a struct and GC
is unable to keep the track of pointers. GC moves the object around or deletes
it, and you have a tiny black hole in your app.
On 07/06/2014 01:45 PM, Wanderer wrote:
On Sunday, 6 July 2014 at 04:20:21 UTC, Timon Gehr wrote:
That's not 'merely holding a pointer' and it applies to class
references just as much.
[...] "proven" that references are as unsafe as
pointers, [...]
If we are talking about 'merely holding' them, sure.
Otherwise, if one manages to serialize and deserialize a class reference
non-deeply, it is obviously just as unsafe to dereference it again after
deserialization as it would be in the case of a pointer.
[...] reference semantics in order to replace pointers and achieve language and
memory safety [...]
To achieve safety, it is sufficient to only allow safe _operations_ on
pointers, there's nothing particularly unsafe about pointers per se.
BTW, in case this discussion is still about settling whether counting
the number of swaps of a sorting algorithm is relevant at all, then
there is a much easier way: There are sorting algorithms where there are
asymptotically more swaps than compares in the respective worst cases.