News for hackers. Stuff that matters.
Re:New school C by aidenn0 on Wednesday December 26, 2012 @01:23PM (#4970230)
A quick example of where circular references are an issue in C++, but weak references aren't needed in other languages. Consider a doubly-linked list, where you remove two nodes from the middle, and those nodes are not reachable from anywhere else. Each node, however, still has a reference to the other:

    X<->Y
In any system with a full GC, those nodes will get freed; in a reference counting system, those nodes will stay around forever.
Re:New school C by alexchamberlain on Wednesday December 26, 2012 @01:48PM (#4970329)
But why have you designed your interface in such a way that this could happen?

A normal interface would allow you to remove one node at a time and this wouldn't occur.

A more advanced interface may allow you to remove 2 nodes, but would return a vector or a new list to ensure proper deallocation.

Don't get me wrong; you have to think with C++ and generally know what you're doing. However, you can write safe and high level C++ and I don't necessarily think thinking about your design is a bad thing.

Re:New school C by aidenn0 on Wednesday December 26, 2012 @07:45PM (#4971749)
I'm not addressing that part; I'm merely pointing out that circular references are solvable without weak references.