No matching definitions.

tur/region

stdlib/region.tur

a declared lifetime bracket, independent of the trail.

Since: RM3 (prototype 2026-09-04; on by default since 2026-09-05)

defn

with-region

(with-region [A])

run `body` inside an arena generation and reclaim it after.

bodya thunk. Taken ^fat, so a capturing lambda works -- which is the
only interesting case, since the body has to build the values
whose lifetime this bounds.

Whatever `body` returned. The VALUE survives; anything it allocated inside that the value does not reach is reclaimed. Returning something that points into reclaimed region memory is refused at compile time by declining to rewind (the value's type is walked); a genuinely escaping pointer the walk cannot see is caught at run time and blocks the rewind. Neither is a memory safety hole -- the failure mode is "no saving", not a stale read.

(with-region (fn [] (sum-of (build-scratch 100))))  ; scratch reclaimed

Since: RM3