diff options
author | Juan Carlos <JuanCarlospaco@gmail.com> | 2020-11-14 15:31:59 -0300 |
---|---|---|
committer | Juan Carlos <JuanCarlospaco@gmail.com> | 2020-11-14 15:31:59 -0300 |
commit | d0dda9efab6bd67d033e30e2ba16820450c38cbe (patch) | |
tree | 6a53d100050eefa0c112317831f70033c6fea0a0 | |
parent | 1978b9120250f69df20a5bbb2cb11e73cd3eae5a (diff) | |
download | Nim-d0dda9efab6bd67d033e30e2ba16820450c38cbe.tar.gz |
Fix #15806
-rw-r--r-- | doc/manual.rst | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index bfcce24cf..bbc8bb225 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 <https://en.wikipedia.org/wiki/Stropping_(syntax)>`_ +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 --------------- |