document ; vs , for generic params (#17192)
This commit is contained in:
parent
ff3ace2232
commit
e9f12dd89e
1 changed files with 6 additions and 1 deletions
|
|
@ -4805,7 +4805,6 @@ The following example shows how a generic binary tree can be modeled:
|
||||||
The ``T`` is called a `generic type parameter`:idx: or
|
The ``T`` is called a `generic type parameter`:idx: or
|
||||||
a `type variable`:idx:.
|
a `type variable`:idx:.
|
||||||
|
|
||||||
|
|
||||||
Is operator
|
Is operator
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
@ -4861,6 +4860,12 @@ more complex type classes:
|
||||||
for key, value in fieldPairs(rec):
|
for key, value in fieldPairs(rec):
|
||||||
echo key, " = ", value
|
echo key, " = ", value
|
||||||
|
|
||||||
|
Type constraints on generic parameters can be grouped with `,` and propagation
|
||||||
|
stops with `;`, similarly to parameters for macros and templates:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
proc fn1[T; U, V: SomeFloat]() = discard # T is unconstrained
|
||||||
|
template fn2(t; u, v: SomeFloat) = discard # t is unconstrained
|
||||||
|
|
||||||
Whilst the syntax of type classes appears to resemble that of ADTs/algebraic data
|
Whilst the syntax of type classes appears to resemble that of ADTs/algebraic data
|
||||||
types in ML-like languages, it should be understood that type classes are static
|
types in ML-like languages, it should be understood that type classes are static
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue