Skip to content

Save state and object graphs

Use Save scope when a binding should persist across restart. Public state is for the running plot program; Private belongs to one routine call.

Declare a Save Number bestScore. On a relevant event, read ${save.bestScore ?? 0} to use zero while it is unassigned/null. This only reads a fallback; use Set Variable if you intend to store the initial zero.

Compare a new result against the stored best before assigning. A Final Save binding cannot be overwritten after its first assignment, so leave changing records non-Final.

Supported Save graphs preserve aliases, cycles, object identity, dictionary identity keys, unassigned fields, and Final assignment state. Two saved references to the same object remain shared; they are not automatically reconstructed as independent copies.

Choose passing modes deliberately before storing a snapshot. Reference retains sharing with other bindings; Deep Copy creates an independent object graph while preserving its internal relationships.

Changing a class or field edits the draft until compilation succeeds. Fix incompatible references before compiling. Removed fields are omitted from saved graphs by successful builds. A failed compilation keeps the previous successful program available.

Avoid treating a recreated same-name field as the original declaration: identities are stable through renames, not arbitrary removal/recreation. Review persistent data changes with small test objects before restructuring a large saved model.

Save does not preserve arbitrary Dev inventory snapshots or make transient runtime entities permanent. Entity Targets still identify real entities, which may no longer exist after cleanup. Check target validity and keep persistent game data as supported values/objects rather than assuming every old entity reference remains usable.