From d0dda9efab6bd67d033e30e2ba16820450c38cbe Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sat, 14 Nov 2020 15:31:59 -0300 Subject: [PATCH 1/5] Fix #15806 --- doc/manual.rst | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/manual.rst b/doc/manual.rst index bfcce24cf3..bbc8bb225a 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -8,7 +8,7 @@ Nim Manual .. contents:: - "Complexity" seems to be a lot like "energy": you can transfer it from the + "Complexity" seems to be a lot like "energy": you can transfer it from the end-user to one/some of the other players, but the total amount seems to remain pretty much constant for a given task. -- Ran @@ -313,6 +313,35 @@ it was not case-sensitive and underscores were ignored and there was not even a distinction between ``foo`` and ``Foo``. +Stropping +--------- + +`Stropping `_ +allows the same letter sequence to be used both as a keyword and as an identifier, and simplifies parsing. +For example, allowing a variable named `if` without clashing with the keyword `if`. +In Nim, this is achieved via backticks, allowing any reserved word to be used as an identifier. + +Examples + +.. code-block:: nim + var `var` = "Hello Stropping" + +.. code-block:: nim + type Type = object + `int`: int + + let `object` = Type(`int`: 9) + assert `object` is Type + assert `object`.`int` == 9 + + var `var` = 42 + let `let` = 8 + assert `var` + `let` == 50 + + const `assert` = true + assert `assert` + + String literals --------------- From 3cebae492e61ccbb29cfc38fbaa1f54270dfeb8a Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sat, 14 Nov 2020 15:39:03 -0300 Subject: [PATCH 2/5] Fix #15806 --- doc/manual.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual.rst b/doc/manual.rst index bbc8bb225a..0656dfa767 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -317,7 +317,8 @@ Stropping --------- `Stropping `_ -allows the same letter sequence to be used both as a keyword and as an identifier, and simplifies parsing. +allows the same letter sequence to be used both as a keyword and as an identifier, +this simplifies parsing and FFI with languages where that identifier is not a reserved keyword. For example, allowing a variable named `if` without clashing with the keyword `if`. In Nim, this is achieved via backticks, allowing any reserved word to be used as an identifier. From 9ab1a86b5bfb8f5647b9f9cb4ab48a5b5eb55707 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sat, 14 Nov 2020 15:43:31 -0300 Subject: [PATCH 3/5] Fix #15806 --- doc/manual.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/manual.rst b/doc/manual.rst index 0656dfa767..6dfff55a63 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -317,8 +317,9 @@ Stropping --------- `Stropping `_ -allows the same letter sequence to be used both as a keyword and as an identifier, -this simplifies parsing and FFI with languages where that identifier is not a reserved keyword. +allows the same letter sequence to be used both as a keyword and as an identifier, this simplifies parsing and +`FFI `_ +with languages where that identifier is not a reserved keyword. For example, allowing a variable named `if` without clashing with the keyword `if`. In Nim, this is achieved via backticks, allowing any reserved word to be used as an identifier. From c56a6133bb3c1d2e862726e10e445d477dd6d15e Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sat, 14 Nov 2020 15:45:13 -0300 Subject: [PATCH 4/5] Fix #15806 --- doc/manual.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual.rst b/doc/manual.rst index 6dfff55a63..c80b60ea0a 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -320,6 +320,7 @@ Stropping allows the same letter sequence to be used both as a keyword and as an identifier, this simplifies parsing and `FFI `_ with languages where that identifier is not a reserved keyword. + For example, allowing a variable named `if` without clashing with the keyword `if`. In Nim, this is achieved via backticks, allowing any reserved word to be used as an identifier. @@ -330,7 +331,7 @@ Examples .. code-block:: nim type Type = object - `int`: int + `int`: int let `object` = Type(`int`: 9) assert `object` is Type From 1b9f37c6dc99b95a2ccee0a51535faf224b31f31 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sat, 14 Nov 2020 19:57:06 -0300 Subject: [PATCH 5/5] https://github.com/nim-lang/Nim/pull/15968/files#r523468677 --- doc/manual.rst | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/doc/manual.rst b/doc/manual.rst index c80b60ea0a..9a4ae378d9 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -316,13 +316,7 @@ distinction between ``foo`` and ``Foo``. Stropping --------- -`Stropping `_ -allows the same letter sequence to be used both as a keyword and as an identifier, this simplifies parsing and -`FFI `_ -with languages where that identifier is not a reserved keyword. - -For example, allowing a variable named `if` without clashing with the keyword `if`. -In Nim, this is achieved via backticks, allowing any reserved word to be used as an identifier. +If a keyword is enclosed in backticks it loses its keyword property and becomes an ordinary identifier. Examples