Corrected manual (Identifier equality) (#6366)
* Corrected manual (Identifier equality) - Clarified that identifiers are only case insensitive for ASCII characters - Removed mention of dash-style, since it has been removed
This commit is contained in:
parent
c35cc97b1e
commit
9aeb78e2a8
1 changed files with 3 additions and 3 deletions
|
|
@ -130,17 +130,17 @@ Two identifiers are considered equal if the following algorithm returns true:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
proc sameIdentifier(a, b: string): bool =
|
proc sameIdentifier(a, b: string): bool =
|
||||||
a[0] == b[0] and
|
a[0] == b[0] and
|
||||||
a.replace("_", "").toLower == b.replace("_", "").toLower
|
a.replace("_", "").toLowerAscii == b.replace("_", "").toLowerAscii
|
||||||
|
|
||||||
That means only the first letters are compared in a case sensitive manner. Other
|
That means only the first letters are compared in a case sensitive manner. Other
|
||||||
letters are compared case insensitively and underscores are ignored.
|
letters are compared case insensitively within the ASCII range and underscores are ignored.
|
||||||
|
|
||||||
This rather unorthodox way to do identifier comparisons is called
|
This rather unorthodox way to do identifier comparisons is called
|
||||||
`partial case insensitivity`:idx: and has some advantages over the conventional
|
`partial case insensitivity`:idx: and has some advantages over the conventional
|
||||||
case sensitivity:
|
case sensitivity:
|
||||||
|
|
||||||
It allows programmers to mostly use their own preferred
|
It allows programmers to mostly use their own preferred
|
||||||
spelling style, be it humpStyle, snake_style or dash–style and libraries written
|
spelling style, be it humpStyle or snake_style, and libraries written
|
||||||
by different programmers cannot use incompatible conventions.
|
by different programmers cannot use incompatible conventions.
|
||||||
A Nim-aware editor or IDE can show the identifiers as preferred.
|
A Nim-aware editor or IDE can show the identifiers as preferred.
|
||||||
Another advantage is that it frees the programmer from remembering
|
Another advantage is that it frees the programmer from remembering
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue