circularAttribute

fun <Node, T> circularAttribute(initial: T, f: Node.() -> T): Attribute<Node, T>

Defines an Attribute of type T for nodes of type Node. Unlike with attribute, attribute definitions are allowed to be circular.

The value of the attribute is computed by the function f, which may itself use the value of the attribute. Attribute values are initialized to initial. The attribute (and any circular attributes on which it depends) are evaluated until no value changes (i.e., a fixed point is reached). The final result is cached so that subsequent evaluations are fast and return the same value.

See also