Library / Collections / Sequences / Box
Box
Defines the Box[T] class per ENVZN_CONSTITUTION §Box.
Constructors 1
INIT(T value)The only constructor. value is consumed (a plain parameter owns). The
compiler's auto-wrap rewrite produces CREATE Box[T](rhs)
when initialising a Box[T] field from a T-typed expression.
Methods 4
METHOD clone() RETURNS Box[T]reads
Hand-written rather than AUTO: Box has no zero-arg INIT (the
user-facing model has no "empty box" state), so the cascade
synthesis path doesn't apply. T must implement Cloneable when
T is a class type; the explicit ->clone() call below
surfaces the requirement as a compile error on the Box[T]
instantiation that triggers it.
METHOD value() RETURNS REFERENCE Treads
── value — return a non-owning handle ────────────────────────
The auto-unwrap rewrite for reads of a Box[T] field. Returns
a non-optional REFERENCE T into SELF's owned .inner.
.inner is always populated (set by INIT and never cleared),
so the reference is always valid; the reference checker proves
it without runtime infrastructure.
METHOD valueClone() RETURNS Treads
── valueClone — return an owned copy ───────────────────────── The path callers take when they need an owning T (e.g. to store elsewhere, to mutate independently). T must be Cloneable; the cascade-failure rule fires at instantiation otherwise.
MODIFY METHOD set(T value) RETURNS voidmodifies
── set — replace the wrapped value ─────────────────────────── Drops the previous inner and installs value (owned). : := to a populated non-Optional owning field drops the previous owner via its destructor, then installs the new owner from the RHS. Box never enters a "moved-out" state observable to the user — the drop and the install happen as a single operator step.