summary refs log tree commit diff stats
path: root/doc/astspec.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/astspec.txt')
-rw-r--r--doc/astspec.txt48
1 files changed, 40 insertions, 8 deletions
diff --git a/doc/astspec.txt b/doc/astspec.txt
index bfaec7155..7a7053a2d 100644
--- a/doc/astspec.txt
+++ b/doc/astspec.txt
@@ -893,7 +893,7 @@ on what keywords are present. Let's start with the simplest form.
 Concrete syntax:
 
   ```nim
-  import math
+  import std/math
   ```
 
 AST:
@@ -907,7 +907,7 @@ With ``except``, we get ``nnkImportExceptStmt``.
 Concrete syntax:
 
   ```nim
-  import math except pow
+  import std/math except pow
   ```
 
 AST:
@@ -916,13 +916,13 @@ AST:
   nnkImportExceptStmt(nnkIdent("math"),nnkIdent("pow"))
   ```
 
-Note that ``import math as m`` does not use a different node; rather,
+Note that ``import std/math as m`` does not use a different node; rather,
 we use ``nnkImportStmt`` with ``as`` as an infix operator.
 
 Concrete syntax:
 
   ```nim
-  import strutils as su
+  import std/strutils as su
   ```
 
 AST:
@@ -945,7 +945,7 @@ If we use ``from ... import``, the result is different, too.
 Concrete syntax:
 
   ```nim
-  from math import pow
+  from std/math import pow
   ```
 
 AST:
@@ -954,7 +954,7 @@ AST:
   nnkFromStmt(nnkIdent("math"), nnkIdent("pow"))
   ```
 
-Using ``from math as m import pow`` works identically to the ``as`` modifier
+Using ``from std/math as m import pow`` works identically to the ``as`` modifier
 with the ``import`` statement, but wrapped in ``nnkFromStmt``.
 
 Export statement
@@ -1348,7 +1348,7 @@ Generic parameters are treated in the type, not the ``proc`` itself.
 Concrete syntax:
 
   ```nim
-  type MyProc[T] = proc(x: T)
+  type MyProc[T] = proc(x: T) {.nimcall.}
   ```
 
 AST:
@@ -1363,7 +1363,8 @@ AST:
     nnkProcTy( # behaves like a procedure declaration from here on
       nnkFormalParams(
         # ...
-      )
+      ),
+      nnkPragma(nnkIdent("nimcall"))
     )
   )
   ```
@@ -1371,6 +1372,37 @@ AST:
 The same syntax applies to ``iterator`` (with ``nnkIteratorTy``), but
 *does not* apply to ``converter`` or ``template``.
 
+Type class versions of these nodes generally share the same node kind but
+without any child nodes. The ``tuple`` type class is represented by
+``nnkTupleClassTy``, while a ``proc`` or ``iterator`` type class with pragmas
+has an ``nnkEmpty`` node in place of the ``nnkFormalParams`` node of a
+concrete ``proc`` or ``iterator`` type node.
+
+  ```nim
+  type TypeClass = proc {.nimcall.} | ref | tuple
+  ```
+
+AST:
+
+  ```nim
+  nnkTypeDef(
+    nnkIdent("TypeClass"),
+    nnkEmpty(),
+    nnkInfix(
+      nnkIdent("|"),
+      nnkProcTy(
+        nnkEmpty(),
+        nnkPragma(nnkIdent("nimcall"))
+      ),
+      nnkInfix(
+        nnkIdent("|"),
+        nnkRefTy(),
+        nnkTupleClassTy()
+      )
+    )
+  )
+  ```
+
 Mixin statement
 ---------------