summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorapense <apense@users.noreply.github.com>2015-06-15 13:30:09 -0400
committerapense <apense@users.noreply.github.com>2015-06-15 13:30:09 -0400
commit7275a035b580627a58aad76a4f5302e05c060afc (patch)
tree790e1227d96e5a96a6a018583f05633d844643fc /doc
parentac6ea4b76dda5ced9ebf10bc7bf58d29aef24748 (diff)
downloadNim-7275a035b580627a58aad76a4f5302e05c060afc.tar.gz
Updated type section a little
Objects are ubiquitous. Concepts don't use ``concept`` in their name.

Really, a lot more could be added here.
Diffstat (limited to 'doc')
-rw-r--r--doc/astspec.txt44
1 files changed, 44 insertions, 0 deletions
diff --git a/doc/astspec.txt b/doc/astspec.txt
index 0d9475749..1f46070df 100644
--- a/doc/astspec.txt
+++ b/doc/astspec.txt
@@ -815,6 +815,50 @@ AST:
     )
   )
 
+Note that not all ``nnkTypeDef`` utilize ``nnkIdent`` as their
+their parameter. One of the most common uses of type declarations
+is to work with objects.
+
+Concrete syntax:
+
+.. code-block:: nim
+  type IO = object of RootObj
+
+AST:
+
+.. code-block:: nim
+  # ...
+  nnkTypeDef(
+    nnkIdent(!"IO"),
+    nnkEmpty(),
+    nnkObjectTy(
+      nnkEmpty(), # no pragmas here
+      nnkOfInherit(
+        nnkIdent(!"RootObj") # inherits from RootObj
+      )
+      nnkEmpty()
+    )
+  )
+
+The usage of ``concept`` (experimental) is similar.
+
+Concrete syntax:
+
+.. code-block:: nim
+  type Con = concept x,y,z
+    (x & y & z) is string
+
+AST:
+
+.. code-block:: nim
+  # ...
+  nnkTypeClassTy( # note this isn't nnkConceptTy!
+    nnkArglist(
+      # ... idents for x, y, z
+    )
+    # ...
+  )
+
 
 Procedure declaration
 ---------------------