Creating an Updated Copy of a Value

An immutable update creates a new value representing the change while older references retain the earlier state.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace a settings edit
  2. Keep nested sharing safe

Trace a settings edit

A report configuration with width 40 and mode draft can give a new value with width 60 and mode draft. Readers holding the old value still observe width 40. Code that owns its inputs should announce such a promise.

Keep nested sharing safe

If both values share a list and later callers mutate that list, neither is a stable snapshot. Store immutable nested values when promising that isolation. See record snapshots.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩