As a fresh Adam in the Nim paradise, I didn't want to start too ambitiously. 
Just do some thinking about and experimenting with naming the other creatures. 
Oof, quite a tough job! I've found 12+ laws of nature so far, that apply to 
both keywords and identifiers:

  1. Most characters above U+001F are allowed (e.g. `déjà_vu`), but some 
require the name to be stropped, e.g. `{`}2nd_thought{`}`, or `{`}echo{`}` as a 
variable name [`{`}` means a backquote]. Forbidden characters are `#`, `,`, 
`;`, and U+007F (DEL), unless quoted as character or string.
  2. Single and double quotes must constitute valid character and string 
values, e.g. `{`}A'b'cde{`}` and `{`}A"bc"de{`}`. Or they must be quoted as 
character or string themselves.
  3. Stropping delimiters cannot be stropped themselves otherwise than quoted 
as character or string.
  4. Spaces and matching pairs of single and double quotes are removed, so `{`} 
A 'b'c de {`}` ⇒ `Abcde`.
  5. The first character after removal of the spaces and quoted is 
case-sensitive.
  6. The next characters are case-insensitive, as far as they are within the 
ASCII range U+0020 – U+007F. In fact, the uppercase letters within this range 
are converted to lowercase. So `ABÇDÉ` ⇒ `AbÇdÉ` (not `Abçdé`).
  7. A single underscore is used for discarding values, as in `let (first, _) = 
(x: 100, y: 50)`.
  8. Underscores are not allowed _(a)_ at the beginning, _(b)_ at the end, 
_(c)_ directly after another underscore, or _(d)_ after an en-dash.
  9. Other underscores are removed, so `A_bc_de` ⇒ `Abcde`.
  10. En-dashes are not allowed _(a)_ at the end or _(b)_ directly before an 
underscore.
  11. En-dashes are not removed. Nevertheless, they are all ignored when 
comparing names, except for an en-dash at the first position.
  12. When you use characters in the ranges U+0020 – U+002F, U+003A – U+003F, 
U+005B – U+005E, and U+007B – U+007E, a plethora of more lenient but also more 
complex rules fall to you. For instance, `{`}_ A __(B C)_.DE!_{`}` is a valid 
variable name, which can be referred to as `{`}_ a __(bc)_.de!_{`}` (you still 
need the spaces around the `a` to make it a valid expression, but the space 
between `b` and `c` can be omitted). So you can start and end an identifier 
with an underscore, if you really want to.



I may have missed something. Actually I'm looking for some bible that describes 
the rules in more detail and in a more consistent way than the empirical ones 
above. But maybe it's too early for that.

Anyway, if I have to distill a commandment from all this, it would be "Stick to 
the alphabet and numbers, or thou willst be driven out of paradise."

Reply via email to