Re: Immutably updating objects
siiky 31 Oct 2022 10:18 UTC
If I understood correctly, I believe the CHICKEN egg typed-records[0]
has just that feature.
(defstruct foo x y z)
This defines a type `foo` with fields `x`, `y` & `z`. Other than the
constructor, getters, and setters, it creates also an `update-foo` that
works like this:
(let* ((foo (make-foo x: 1 y: 2 z: 3))
(foo (update-foo foo x: 4)))
(foo-x foo)) ;=> 4
[0]: https://wiki.call-cc.org/eggref/5/typed-records