4 ms·
Except this won't work when multiple pointers exist to the same data.. which is arguably when this kind of stuff is most difficult
by TheSoftwareGuy 9y ago
Except this won't work when multiple pointers exist to the same data.. which is arguably when this kind of stuff is most difficult
- lossolo 9y agoIf you have multiple pointers to the same data with different lifetimes you already need some kind of reference counting or garbage collection.
- ktRolster 9y agoThat's why "safer" :) It works in the vast majority of cases. In the rare other cases, you should spend some extra thought on your pointer usage to make sure you have a set of abstractions that let a human reason about the memory sensibly (either that or an insane number of test cases to catch any problem). Someone else mentioned reference counting, and that can be a good idea. The bottom line is you need to do something to make sure you're not doing use-after-free, and it's mostly not difficult.
- marcosdumay 9y agoIt works on most cases that people normally get right, and is useless on most cases that people normally get wrong. Overall, it's not useless, but it's really not worth modifying the language for it.