!7 // Makes the Concept.Ref object unnecessary by directly // storing the reference in a field. // We can probably get rid of the refs field in the same go. // Of course, backRefs are still needed. // TODO: We need backRefs to be able to store concepts also // (by changing its type to L). // Or we add another field directBackRefs. sbool isConceptRefValid(Concept src, Concept dest) { ret src != null && dest != null && src._concepts != null && src._concepts == dest._concepts; } svoid indexConceptRef(Concept src, Concept dest) { if (isConceptRefValid(src, dest)) { // dest._addBackRef(src); change(); } } svoid unindexConceptRef(Concept src, Concept dest) {} sO conceptRefMutex(Concept c) { ret or(c._concepts, dummyMutex()); } concept Thing { Thing ref_ptr; // setter selfType ref(Thing dest) { synchronized(conceptRefMutex(this)) { if (ref_ptr != dest) { unindexConceptRef(this, ref_ptr); ref_ptr = dest; indexConceptRef(this, dest); } } this; } // getter. we could get rid of this by making the field // publicly accessible, but then we run the slight chance // of setting it without the setter inadvertently. Thing ref() { ret ref_ptr; } } cprint {}