dyn-with

Symbol: compile/dyn-with

Syntax: (dyn-with [name? expr] body ...)

Same syntax as with; optional name binds the enter result.

Use-case: Multi-shot context manager that participates in continuation transfer plans (shift/reset, undelimited call/cc). On non-local transfer, enter/exit run as wind/unwind steps; re-entry creates a fresh extent instance.

Behaviour: Same as with except emits PUSH_DYN_WITH and POP_DYN_WITH. The expression value is the body’s value, or None when the exit swallows an exception. See PUSH_DYN_WITH / POP_DYN_WITH in the VM reference.

Examples:

;; Capture continuation inside dyn-with; invoke outside runs exit then enter
(dyn-with [r (make-resource)]
  (k (refq r)))