Atom

runtime.weak()

Creates a weak accessor.

Signature

runtime.weak(target)

Parameters

Managed object, such as a string, collection, closure or packed value.

Returns

Zero-argument function returning the target or null after collection.

Behavior

Does not keep the target live. A successful lookup returns an ordinary strong reference.

Errors

Immediate values and type descriptors cannot be weak targets.

Example

Atom
use runtime
a = []
probe = runtime.weak(a)
assert(probe() == a)