manual: Document that comma propagates the default values of parameters (#19080)

* manual: Document that comma propagates the default values of parameters

Fixes https://github.com/nim-lang/Nim/issues/15949.

* Use the "bug #NNNN" comment syntax for consistency

Ref:
https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib

> Always refer to a GitHub issue using the following exact syntax: bug
for tooling.
This commit is contained in:
Kaushal Modi
2021-11-03 03:08:50 -04:00
committed by GitHub
parent 5fed1c05ce
commit dbbafd320c
2 changed files with 29 additions and 1 deletions

View File

@@ -3603,9 +3603,17 @@ does not provide a value for the argument. The value will be reevaluated
every time the function is called.
.. code-block:: nim
# b is optional with 47 as its default value
# b is optional with 47 as its default value.
proc foo(a: int, b: int = 47): int
Just as the comma propagates the types from right to left until the
first parameter or until a semicolon is hit, it also propagates the
default value starting from the parameter declared with it.
.. code-block:: nim
# Both a and b are optional with 47 as their default values.
proc foo(a, b: int = 47): int
Parameters can be declared mutable and so allow the proc to modify those
arguments, by using the type modifier `var`.