ezyang’s blog

the arc of software bends towards understanding

Type kata: Controlled sharing of references

The imperative. Mutable data structures with many children frequently force any given child to be associated with one given parent data structure: class DOMNode { private DOMDocument $ownerDocument; // ... public void appendNode(DOMNode n) { if (n.ownerDocument != this.ownerDocument) { throw DOMException("Cannot append node that " "does not belong to this document"); } // ... […]

  • August 18, 2010