summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-02-26 07:14:25 -0800
committerGitHub <noreply@github.com>2021-02-26 16:14:25 +0100
commite9f12dd89e0b37eda11bf506415b6248aa967862 (patch)
tree505d211dc461213fe1e6f52c69717644729790af
parentff3ace2232ee32381ceaa50edb29f64dbd2289ea (diff)
downloadNim-e9f12dd89e0b37eda11bf506415b6248aa967862.tar.gz
document `;` vs `,` for generic params (#17192)
-rw-r--r--doc/manual.rst7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/manual.rst b/doc/manual.rst
index 5aca1be80..92235821b 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -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
 a `type variable`:idx:.
 
-
 Is operator
 -----------
 
@@ -4861,6 +4860,12 @@ more complex type classes:
     for key, value in fieldPairs(rec):
       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
 types in ML-like languages, it should be understood that type classes are static