manual: minor improvements (#18687)

This commit is contained in:
Andreas Rumpf 2021-08-13 12:34:28 +02:00 • committed by GitHub
commit 4463a3c3d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,7 @@ the `destructors <destructors.html>`_ document.
This document describes the lexis, the syntax, and the semantics of the Nim language. This document describes the lexis, the syntax, and the semantics of the Nim language.
To learn how to compile Nim programs and generate documentation see To learn how to compile Nim programs and generate documentation see
`Compiler User Guide <nimc.html>`_ and `DocGen Tools Guide <docgen.html>`_. the `Compiler User Guide <nimc.html>`_ and the `DocGen Tools Guide <docgen.html>`_.
The language constructs are explained using an extended BNF, in which `(a)*` The language constructs are explained using an extended BNF, in which `(a)*`
means 0 or more `a`'s, `a+` means 1 or more `a`'s, and `(a)?` means an means 0 or more `a`'s, `a+` means 1 or more `a`'s, and `(a)?` means an
@ -583,12 +583,11 @@ In the following examples, `-1` is parsed as two separate tokens
"abc"-1 "abc"-1
There exists a literal for each numerical type that is The suffix starting with an apostrophe ('\'') is called a
defined. The suffix starting with an apostrophe ('\'') is called a
`type suffix`:idx:. Literals without a type suffix are of an integer type `type suffix`:idx:. Literals without a type suffix are of an integer type
unless the literal contains a dot or `E|e` in which case it is of unless the literal contains a dot or `E|e` in which case it is of
type `float`. This integer type is `int` if the literal is in the range type `float`. This integer type is `int` if the literal is in the range
`low(i32)..high(i32)`, otherwise it is `int64`. `low(int32)..high(int32)`, otherwise it is `int64`.
For notational convenience, the apostrophe of a type suffix For notational convenience, the apostrophe of a type suffix
is optional if it is not ambiguous (only hexadecimal floating-point literals is optional if it is not ambiguous (only hexadecimal floating-point literals
with a type suffix can be ambiguous). with a type suffix can be ambiguous).
@ -619,10 +618,9 @@ notation:
`0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64` `0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64`
is approximately 1.72826e35 according to the IEEE floating-point standard. is approximately 1.72826e35 according to the IEEE floating-point standard.
Literals are bounds checked so that they fit the datatype. Non-base-10 Literals must match the datatype, for example, `333'i8` is an invalid literal.
literals are used mainly for flags and bit pattern representations, therefore Non-base-10 literals are used mainly for flags and bit pattern representations,
bounds checking is done on bit width, not value range. If the literal fits in therefore the checking is done on bit width and not on value range.
the bit width of the datatype, it is accepted.
Hence: 0b10000000'u8 == 0x80'u8 == 128, but, 0b10000000'i8 == 0x80'i8 == -1 Hence: 0b10000000'u8 == 0x80'u8 == 128, but, 0b10000000'i8 == 0x80'i8 == -1
instead of causing an overflow error. instead of causing an overflow error.
@ -1980,8 +1978,7 @@ details like this when mixing garbage-collected data with unmanaged memory.
Procedural type Procedural type
--------------- ---------------
A procedural type is internally a pointer to a procedure. `nil` is A procedural type is internally a pointer to a procedure. `nil` is
an allowed value for variables of a procedural type. Nim uses procedural an allowed value for a variable of a procedural type.
types to achieve `functional`:idx: programming techniques.
Examples: Examples:
@ -2494,8 +2491,8 @@ An expression `b` can be assigned to an expression `a` iff `a` is an
`l-value` and `isImplicitlyConvertible(b.typ, a.typ)` holds. `l-value` and `isImplicitlyConvertible(b.typ, a.typ)` holds.
Overloading resolution Overload resolution
====================== ===================
In a call `p(args)` the routine `p` that matches best is selected. If In a call `p(args)` the routine `p` that matches best is selected. If
multiple routines match equally well, the ambiguity is reported during multiple routines match equally well, the ambiguity is reported during