On Jan 6, 2007, at 1:16 AM, Mars Saxman wrote:

It's actually pretty trivial to implement weak references with a plugin, all
you need to do is return the object without locking it.

This is trivial only because it leaves the hard part of the problem unsolved. When the object reaches the end of its life, all of these fake "weak references" will become dangling references, pointing at an object which no longer exists. Breaking the memory management system like this is not a good idea unless you have too much free time and want to spend it solving tricky bugs.

Surely, it would still be useful if you know about this and take account of it.

In particular, if you know where all the dangling references to an object are going to be, you can delete them in that object's destructor. I would imagine that most designs that could benefit weak references could do this reasonably easily.

What I would like to see is the ability to write our own weak reference implementation. What would suffice for this is the ability to get an object from its ID and vice-versa. This way, we could keep a "reference" to an object as an integer. It would be up to grown-up programmers to use this intelligently eg in the manner discussed above, to delete such "references" in an object's destructor.

Not perfect, but close enough to implement a lot of things that are flat-out impossible right now without explicit memory management (UGH!).

Unless we're going to get weak references soon, please consider giving us this.

Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to