From cdc6c866ca087ba738f0a5d01cc0fc6ddc066935 Mon Sep 17 00:00:00 2001 From: Alexander Lyashuk Date: Wed, 28 Apr 2021 06:39:56 +0200 Subject: 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`. --- docs/markdown/Syntax.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docs/markdown') 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] -- cgit v1.1