[<<][c][>>][..]
Mon Jul 26 14:07:25 CEST 2010

Hiding circular dependencies using "temporary binding".

If you stick to proper trees as datastructures for C programs, you can
avoid memory allocation problems.  

In such case each datastructure has exactly one owner/parent/... an
can in principle be _embedded_ in that larger structure.

If you need directed, acyclic graphs, you need reference counting.

If you need generic cyclic object reference graphs, you need
asynchronous GC.

However, in many cases it is possible to go back to DAG / tree rep by
providing a "temporary binding" object that associates 2 objects that
need to know about each other.

This requires a rule that methods cannot store pointers to other
objects, but they might be "temporarily bound" during the execution of
one method.  The binding object (the one that actually stores the two
pointers) is then responsible for the management of the two pointers.

This is actually dependency injection[1] combined with a `short-lived
clause': object only live during method call.

In the DAG case, another trick is to impose an order on the data
structure.  The simplest one is the call stack: if a DAG is built only
from local variables, simply returning functions will properly
cleanup.

FIXME: de-ramble

[1] http://en.wikipedia.org/wiki/Dependency_injection


[Reply][About]
[<<][c][>>][..]