aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lyashuk <mooskagh@gmail.com>2021-04-28 06:39:56 +0200
committerGitHub <noreply@github.com>2021-04-28 00:39:56 -0400
commitcdc6c866ca087ba738f0a5d01cc0fc6ddc066935 (patch)
treee67bd4b25cb850fb5288e3e1b336f3163ab6b0fd
parenta493c950a73c5924e1e2f9454a5c13d0c7bc93bc (diff)
downloadmeson-cdc6c866ca087ba738f0a5d01cc0fc6ddc066935.zip
meson-cdc6c866ca087ba738f0a5d01cc0fc6ddc066935.tar.gz
meson-cdc6c866ca087ba738f0a5d01cc0fc6ddc066935.tar.bz2
doc: update syntax description of immutability
"Stored by value" is more correct way to explain that example. Mutable vs immutable means that you cannot mutate the value (e.g. list vs tuple in Python), and the example shows that `var2` is actually mutable. Copying/storing a reference vs value is what what matters in the assignment, in Python `a=b` means `a` and `b` are references to the same list, while in meson `a=b` copies the value of `b` into `a`.
-rw-r--r--docs/markdown/Syntax.md6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md
index 4e3d422..be3292f 100644
--- a/docs/markdown/Syntax.md
+++ b/docs/markdown/Syntax.md
@@ -36,8 +36,10 @@ var2 = 102
```
One important difference in how variables work in Meson is that all
-objects are immutable. This is different from, for example, how Python
-works.
+objects are immutable. When you see an operation which appears like
+a mutation, actually a new object is created and assigned to the
+name. This is different from, for example, how Python works for
+objects, but similar to e.g. Python strings.
```meson
var1 = [1, 2, 3]