diff --git a/1-ProceduralProgramming/0-main.ipynb b/1-ProceduralProgramming/0-main.ipynb index 2eac05b201197bfac22bf8388b84cef9f1d703aa..e19dc4614f5a16111fa5cf29d0939e8865a68f13 100644 --- a/1-ProceduralProgramming/0-main.ipynb +++ b/1-ProceduralProgramming/0-main.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "* [Variables, initialisation, affectation](./1-Variables.ipynb)\n", + "* [Variables, initialisation, assignment](./1-Variables.ipynb)\n", "* [Condition and loops](./2-Conditions-and-loops.ipynb)\n", " * [Hands-on 1](./2b-hands-on.ipynb)\n", "* [Predefined types](./3-Types.ipynb)\n", @@ -29,8 +29,7 @@ "source": [ "\n", "[© Copyright](../COPYRIGHT.md) \n", - "", - "" + "\n" ] } ], diff --git a/1-ProceduralProgramming/1-Variables.ipynb b/1-ProceduralProgramming/1-Variables.ipynb index 866f0922deb7371d13a727b6e082f981da815001..0003bf2619cc4a5863ab6067be5b3c0bb5e90c34 100644 --- a/1-ProceduralProgramming/1-Variables.ipynb +++ b/1-ProceduralProgramming/1-Variables.ipynb @@ -14,7 +14,7 @@ }, "source": [ "<h1>Table of contents<span class=\"tocSkip\"></span></h1>\n", - "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Ordinary-variables\" data-toc-modified-id=\"Ordinary-variables-1\">Ordinary variables</a></span><ul class=\"toc-item\"><li><span><a href=\"#Declaration\" data-toc-modified-id=\"Declaration-1.1\">Declaration</a></span></li><li><span><a href=\"#Initialisation\" data-toc-modified-id=\"Initialisation-1.2\">Initialisation</a></span></li><li><span><a href=\"#Affectation\" data-toc-modified-id=\"Affectation-1.3\">Affectation</a></span></li><li><span><a href=\"#Scope-and-blocks\" data-toc-modified-id=\"Scope-and-blocks-1.4\">Scope and blocks</a></span></li><li><span><a href=\"#Increment-and-decrement-operators\" data-toc-modified-id=\"Increment-and-decrement-operators-1.5\">Increment and decrement operators</a></span></li><li><span><a href=\"#Comparing-values\" data-toc-modified-id=\"Comparing-values-1.6\">Comparing values</a></span></li></ul></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-2\">References</a></span></li><li><span><a href=\"#Pointers\" data-toc-modified-id=\"Pointers-3\">Pointers</a></span><ul class=\"toc-item\"><li><span><a href=\"#Cheatsheet:-pointers-and-reference-syntax\" data-toc-modified-id=\"Cheatsheet:-pointers-and-reference-syntax-3.1\">Cheatsheet: pointers and reference syntax</a></span></li><li><span><a href=\"#Chaining-pointers\" data-toc-modified-id=\"Chaining-pointers-3.2\">Chaining pointers</a></span></li><li><span><a href=\"#nullptr\" data-toc-modified-id=\"nullptr-3.3\"><code>nullptr</code></a></span></li></ul></li><li><span><a href=\"#Constant-variables-and-pointers\" data-toc-modified-id=\"Constant-variables-and-pointers-4\">Constant variables and pointers</a></span></li><li><span><a href=\"#Arrays\" data-toc-modified-id=\"Arrays-5\">Arrays</a></span><ul class=\"toc-item\"><li><span><a href=\"#Arrays-and-pointers\" data-toc-modified-id=\"Arrays-and-pointers-5.1\">Arrays and pointers</a></span></li></ul></li></ul></div>" + "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Ordinary-variables\" data-toc-modified-id=\"Ordinary-variables-1\">Ordinary variables</a></span><ul class=\"toc-item\"><li><span><a href=\"#Declaration\" data-toc-modified-id=\"Declaration-1.1\">Declaration</a></span></li><li><span><a href=\"#Initialisation\" data-toc-modified-id=\"Initialisation-1.2\">Initialisation</a></span></li><li><span><a href=\"#Assignment\" data-toc-modified-id=\"Assignment-1.3\">Assignment</a></span></li><li><span><a href=\"#Scope-and-blocks\" data-toc-modified-id=\"Scope-and-blocks-1.4\">Scope and blocks</a></span></li><li><span><a href=\"#Increment-and-decrement-operators\" data-toc-modified-id=\"Increment-and-decrement-operators-1.5\">Increment and decrement operators</a></span></li><li><span><a href=\"#Comparing-values\" data-toc-modified-id=\"Comparing-values-1.6\">Comparing values</a></span></li></ul></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-2\">References</a></span></li><li><span><a href=\"#Pointers\" data-toc-modified-id=\"Pointers-3\">Pointers</a></span><ul class=\"toc-item\"><li><span><a href=\"#Cheatsheet:-pointers-and-reference-syntax\" data-toc-modified-id=\"Cheatsheet:-pointers-and-reference-syntax-3.1\">Cheatsheet: pointers and reference syntax</a></span></li><li><span><a href=\"#Chaining-pointers\" data-toc-modified-id=\"Chaining-pointers-3.2\">Chaining pointers</a></span></li><li><span><a href=\"#nullptr\" data-toc-modified-id=\"nullptr-3.3\"><code>nullptr</code></a></span></li></ul></li><li><span><a href=\"#Constant-variables-and-pointers\" data-toc-modified-id=\"Constant-variables-and-pointers-4\">Constant variables and pointers</a></span></li><li><span><a href=\"#Arrays\" data-toc-modified-id=\"Arrays-5\">Arrays</a></span><ul class=\"toc-item\"><li><span><a href=\"#Arrays-and-pointers\" data-toc-modified-id=\"Arrays-and-pointers-5.1\">Arrays and pointers</a></span></li></ul></li></ul></div>" ] }, { @@ -126,10 +126,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Affectation\n", + "### Assignment\n", "\n", - "A new value is stored in an existing variable using the operator\n", - "of assignment `=`. The name of the variable is on the left; the expression\n", + "A new value is stored in an existing variable using the assignment\n", + "operator `=`. The name of the variable is on the left; the expression\n", "on the right of the `=` sign is evaluated, and its result is assigned to the variable." ] }, @@ -150,7 +150,7 @@ " b = 7;\n", " c = a + b;\n", " \n", - " std::cout << \"After affectations: a = \" << a << \", b = \" << b << \" and c = \" << c << std::endl;\n", + " std::cout << \"After assignments: a = \" << a << \", b = \" << b << \" and c = \" << c << std::endl;\n", " \n", "} " ] @@ -159,7 +159,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Affectations may be chained:" + "Assignments may be chained:" ] }, { @@ -393,7 +393,7 @@ "source": [ "### Comparing values\n", "\n", - "As shown above, `=` is the affectation operator. To compare two values, the symbol to use is `==`.\n", + "As shown above, `=` is the assignment operator. To compare two values, the symbol to use is `==`.\n", "\n", "Other comparison operators are:\n", "\n", diff --git a/1-ProceduralProgramming/3-Types.ipynb b/1-ProceduralProgramming/3-Types.ipynb index e440953ea201533678ca513b638d05de80c60044..2a2e537e1d71320e6ac0da1339c80c7fd51bf4b7 100644 --- a/1-ProceduralProgramming/3-Types.ipynb +++ b/1-ProceduralProgramming/3-Types.ipynb @@ -674,7 +674,7 @@ "metadata": {}, "outputs": [], "source": [ - "copy = hello; // please notice affectation is much more straightforward\n", + "copy = hello; // please notice assignment is much more straightforward\n", "std::cout << \"String '\" << copy << \"' is \" << copy.length() << \" characters long.\" << std::endl;" ] }, diff --git a/3-Operators/0-main.ipynb b/3-Operators/0-main.ipynb index 400790e6053205f0eb5e253c7a788a4d7ce07dac..bd4ba74a5d23a7f7effe0f6247a49bd249316577 100644 --- a/3-Operators/0-main.ipynb +++ b/3-Operators/0-main.ipynb @@ -16,7 +16,7 @@ "* [Comparison operators](./2-Comparison.ipynb)\n", "* [Stream operators](./3-Stream.ipynb)\n", " * [Hands-on 10](./3b-hands-on.ipynb)\n", - "* [Affectation operator and the canonical form of a class](./4-CanonicalForm.ipynb)\n", + "* [Assignment operator and the canonical form of a class](./4-CanonicalForm.ipynb)\n", "* [Functors](./5-Functors.ipynb)\n", " * [Hands-on 11](./5b-hands-on.ipynb)" ] @@ -27,8 +27,7 @@ "source": [ "\n", "[© Copyright](../COPYRIGHT.md) \n", - "", - "" + "\n" ] } ], diff --git a/3-Operators/4-CanonicalForm.ipynb b/3-Operators/4-CanonicalForm.ipynb index 77e1ceb785cba24a7b277e3742a53b1c7d911cea..023f4f7c4bddfec4fcb3cfff4e38dabace611c65 100644 --- a/3-Operators/4-CanonicalForm.ipynb +++ b/3-Operators/4-CanonicalForm.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](./) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Affectation operator and the canonical form of a class](/notebooks/3-Operators/4-CanonicalForm.ipynb)" + "# [Getting started in C++](./) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Assignment operator and the canonical form of a class](/notebooks/3-Operators/4-CanonicalForm.ipynb)" ] }, { @@ -14,14 +14,14 @@ }, "source": [ "<h1>Table of contents<span class=\"tocSkip\"></span></h1>\n", - "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Affectation-operator\" data-toc-modified-id=\"Affectation-operator-1\">Affectation operator</a></span><ul class=\"toc-item\"><li><span><a href=\"#Default-behaviour-(for-a-simple-case)\" data-toc-modified-id=\"Default-behaviour-(for-a-simple-case)-1.1\">Default behaviour (for a simple case)</a></span></li><li><span><a href=\"#The-pointer-case\" data-toc-modified-id=\"The-pointer-case-1.2\">The pointer case</a></span></li><li><span><a href=\"#Uncopyable-class\" data-toc-modified-id=\"Uncopyable-class-1.3\">Uncopyable class</a></span></li><li><span><a href=\"#Copy-constructor\" data-toc-modified-id=\"Copy-constructor-1.4\">Copy constructor</a></span></li><li><span><a href=\"#The-dangers-of-copy-constructions...-and-how-I-avoid-them\" data-toc-modified-id=\"The-dangers-of-copy-constructions...-and-how-I-avoid-them-1.5\">The dangers of copy constructions... and how I avoid them</a></span></li></ul></li><li><span><a href=\"#Canonical-form-of-a-class\" data-toc-modified-id=\"Canonical-form-of-a-class-2\">Canonical form of a class</a></span><ul class=\"toc-item\"><li><span><a href=\"#[Advanced]-The-true-canonical-class\" data-toc-modified-id=\"[Advanced]-The-true-canonical-class-2.1\">[Advanced] The true canonical class</a></span></li></ul></li></ul></div>" + "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Assignment-operator\" data-toc-modified-id=\"Assignment-operator-1\">Assignment operator</a></span><ul class=\"toc-item\"><li><span><a href=\"#Default-behaviour-(for-a-simple-case)\" data-toc-modified-id=\"Default-behaviour-(for-a-simple-case)-1.1\">Default behaviour (for a simple case)</a></span></li><li><span><a href=\"#The-pointer-case\" data-toc-modified-id=\"The-pointer-case-1.2\">The pointer case</a></span></li><li><span><a href=\"#Uncopyable-class\" data-toc-modified-id=\"Uncopyable-class-1.3\">Uncopyable class</a></span></li><li><span><a href=\"#Copy-constructor\" data-toc-modified-id=\"Copy-constructor-1.4\">Copy constructor</a></span></li><li><span><a href=\"#The-dangers-of-copy-constructions...-and-how-I-avoid-them\" data-toc-modified-id=\"The-dangers-of-copy-constructions...-and-how-I-avoid-them-1.5\">The dangers of copy constructions... and how I avoid them</a></span></li></ul></li><li><span><a href=\"#Canonical-form-of-a-class\" data-toc-modified-id=\"Canonical-form-of-a-class-2\">Canonical form of a class</a></span><ul class=\"toc-item\"><li><span><a href=\"#[Advanced]-The-true-canonical-class\" data-toc-modified-id=\"[Advanced]-The-true-canonical-class-2.1\">[Advanced] The true canonical class</a></span></li></ul></li></ul></div>" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Affectation operator\n", + "## Assignment operator\n", "\n", "We have not yet addressed one of the most natural operator: the one that might be used to allocate a value to an object. \n", "\n", @@ -301,7 +301,7 @@ "source": [ "### Uncopyable class\n", "\n", - "In fact when I said by default an affectation operator is made available for the class, I was overly simplifying the issue. Let's consider for instance a class with a reference data attribute:" + "In fact when I said by default an assignment operator is made available for the class, I was overly simplifying the issue. Let's consider for instance a class with a reference data attribute:" ] }, { @@ -431,7 +431,7 @@ "source": [ "There are effectively two ways to copy an object:\n", "\n", - "* With an affectation operator.\n", + "* With an assignment operator.\n", "* With a copy constructor.\n", "\n", "It is NOT the same underlying method which is called under the hood, you might have a different behaviour depending on which one is called or not!" @@ -445,9 +445,9 @@ "\n", "Copy construction may in fact be quite dangerous:\n", "\n", - "* As we've just seen, affectation and construction may differ in implementation, which is not a good thing. There are ways to define one in function of the other (see for instance item 11 of \\cite{Meyers2005}) but they aren't that trivial.\n", + "* As we've just seen, assignment and construction may differ in implementation, which is not a good thing. There are ways to define one in function of the other (see for instance item 11 of \\cite{Meyers2005}) but they aren't that trivial.\n", "* Depending on somewhat complicated rules that have evolved with standard versions, some might or might not be defined implicitly.\n", - "* More importantly, affectation operators may be a nightmare to maintain. Imagine you have a class for which you overload manually the affectation operator and/or the copy constructor. If later you add a new data attribute, you have to make sure not to forget to add it in both implementations; if you forget once you will enter the real of undefined behaviour... and good luck for you to find the origin of the bug!\n", + "* More importantly, assignment operators may be a nightmare to maintain. Imagine you have a class for which you overload manually the assignment operator and/or the copy constructor. If later you add a new data attribute, you have to make sure not to forget to add it in both implementations; if you forget once you will enter the real of undefined behaviour... and good luck for you to find the origin of the bug!\n", "\n", "To avoid that I took the extreme rule to (almost) never overload those myself:\n", "\n", @@ -485,7 +485,7 @@ " //! Disable copy constructor.\n", " AlmostCanonicalClass(const AlmostCanonicalClass& ) = delete;\n", " \n", - " //! Disable copy affectation.\n", + " //! Disable copy assignment.\n", " AlmostCanonicalClass& operator=(const AlmostCanonicalClass& ) = delete; \n", "};" ] @@ -525,13 +525,13 @@ " //! Disable copy constructor.\n", " TrueCanonicalClass(const TrueCanonicalClass& ) = delete;\n", " \n", - " //! Disable copy affectation.\n", + " //! Disable copy assignment.\n", " TrueCanonicalClass& operator=(const TrueCanonicalClass& ) = delete; \n", " \n", " //! Disable move constructor.\n", " TrueCanonicalClass(TrueCanonicalClass&& ) = delete;\n", " \n", - " //! Disable move affectation.\n", + " //! Disable move assignment.\n", " TrueCanonicalClass& operator=(TrueCanonicalClass&& ) = delete; \n", "};" ] diff --git a/6-InRealEnvironment/5-Namespace.ipynb b/6-InRealEnvironment/5-Namespace.ipynb index 2f899b3b2eb3ff0cd096f1b81edc27fa2a10b65f..86c721f336a07182ee4a3993d2c0c2c1d407b5ac 100644 --- a/6-InRealEnvironment/5-Namespace.ipynb +++ b/6-InRealEnvironment/5-Namespace.ipynb @@ -552,7 +552,7 @@ "source": [ "### Namespace shortcut\n", "\n", - "You may also in a file use a shortcut if you wish; you thus avoid the caveats we mentioned (as possible cost of readability if you abuse the feature). To do so, you use an affectation like syntax with namespaces:" + "You may also in a file use a shortcut if you wish; you thus avoid the caveats we mentioned (as possible cost of readability if you abuse the feature). To do so, you use an assignment-like syntax with namespaces:" ] }, { @@ -625,8 +625,7 @@ "source": [ "\n", "[© Copyright](../COPYRIGHT.md) \n", - "", - "" + "\n" ] } ], diff --git a/7-Appendix/HomemadeException.ipynb b/7-Appendix/HomemadeException.ipynb index b7b57c0a070e73ce852c189dd216f0a7f93cefc4..1623d2646468609345d95c0d9f3a705e0da89b21 100644 --- a/7-Appendix/HomemadeException.ipynb +++ b/7-Appendix/HomemadeException.ipynb @@ -152,10 +152,10 @@ " //! Move constructor.\n", " Exception(Exception&&) = default;\n", "\n", - " //! Copy affectation.\n", + " //! Copy assignment.\n", " Exception& operator=(const Exception&) = default;\n", "\n", - " //! Move affectation.\n", + " //! Move assignment.\n", " Exception& operator=(Exception&&) = default;\n", "\n", " ///@}\n", @@ -297,8 +297,7 @@ "source": [ "\n", "[© Copyright](../COPYRIGHT.md) \n", - "", - "" + "\n" ] } ],