You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`put` returns a new map that shares everything it can with the original. The copy is cheap thanks to structural sharing—Phel only allocates the path that actually changed.
35
+
`put` returns a new map that shares everything it can with the original. The copy is cheap thanks to structural sharing, Phel only allocates the path that actually changed.
36
36
37
-
## Benefits of data that never moves
37
+
## Benefits of data that never changes
38
38
39
-
-**Predictable functions**: When inputs stay frozen, the only way to change results is to change the arguments. That keeps functions referentially transparent and stops ghost bugs.
40
-
-**Stress-free tests**: Pure functions are a breeze to unit test—you pass data in, check the value coming out, and never mock hidden state changes.
41
-
-**Simpler debugging**: Log a value once and you can trust it forever. Nothing mutates underneath any traces.
42
-
-**Effortless concurrency**: Share the same collection between threads or async tasks with zero drama.
39
+
-**Predictable functions**: With immutable inputs, the only variable is the arguments themselves. This guarantees referential transparency and eliminates hidden, hard-to-trace bugs.
40
+
-**Stress-free tests**: Testing pure functions is effortless, just pass in data, check the result, and forget about mocking or side effects.
41
+
-**Simpler debugging**: Log it once, and it stays true, no sneaky mutations hiding under your traces.
42
+
-**Effortless concurrency**: Pass the same data between async jobs without race conditions or surprises.
43
43
44
44
## Transforming data in steps
45
45
@@ -62,6 +62,8 @@ The vector `scores` is still the same after the reduction, ready to reuse later.
62
62
63
63
## Managing change at the edges
64
64
65
-
Of course, real systems still have to talk to databases, HTTP clients, or the filesystem. Immutability just asks you to fence off those effectful bits. Keep updates at well-defined entry points, translate external state into immutable Phel values, and let the rest of your code cruise on pure data. When you do need a new version, reach for helpers like `put-in`, `unset`, or `push` and pass the result forward.
65
+
Real programs still need to talk to the outside world; databases, APIs, the filesystem. Immutability doesn’t stop that; it just asks you to keep those side effects in their own little corner.
66
66
67
-
Once you stop mutating data in place, your mental load shrinks: there's the value you received, and the value you return. **That's it**. Everything else becomes easier to trust — and that's why, in Phel, your data should never change.
67
+
Do your updates at clear entry points, turn any external data into immutable Phel values, and let the rest of your code run safely on pure data. When you need a new version, use helpers like `put-in`, `unset`, or `push`, and pass the new value forward instead of mutating it.
68
+
69
+
Once you stop changing data in place, life gets simpler: there’s the value you got, and the value you return. **That's it**. Everything else becomes easier to trust, and that’s why, in Phel, your data never changes.
0 commit comments