diff options
author | Mamy Ratsimbazafy <mratsim@users.noreply.github.com> | 2017-11-15 22:01:28 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-11-15 22:01:28 +0100 |
commit | e7c09512d23d34f97d3c853d232572b90a45fd7d (patch) | |
tree | d88af1704620cce91568b5d2799f83d6009eb290 /doc/tut2.rst | |
parent | ac5dff2e04f4f8e2c4aa6537e89d26c2ca09b946 (diff) | |
download | Nim-e7c09512d23d34f97d3c853d232572b90a45fd7d.tar.gz |
Documentation: directly use ref object + fields (#6598)
Diffstat (limited to 'doc/tut2.rst')
-rw-r--r-- | doc/tut2.rst | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/doc/tut2.rst b/doc/tut2.rst index 0bb4c94e1..0636c4ed6 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -104,15 +104,14 @@ Example: .. code-block:: nim type - Node = ref NodeObj # a traced reference to a NodeObj - NodeObj = object + Node = ref object # a reference to an object with the following field: le, ri: Node # left and right subtrees sym: ref Sym # leaves contain a reference to a Sym Sym = object # a symbol name: string # the symbol's name line: int # the line the symbol was declared in - code: Node # the symbol's abstract syntax tree + code: Node # the symbol's abstract syntax tree Type conversions @@ -155,8 +154,7 @@ An example: nkAdd, # an addition nkSub, # a subtraction nkIf # an if statement - Node = ref NodeObj - NodeObj = object + Node = ref object case kind: NodeKind # the ``kind`` field is the discriminator of nkInt: intVal: int of nkFloat: floatVal: float @@ -482,11 +480,10 @@ containers: .. code-block:: nim type - BinaryTreeObj[T] = object # BinaryTree is a generic type with - # with generic param ``T`` - le, ri: BinaryTree[T] # left and right subtrees; may be nil - data: T # the data stored in a node - BinaryTree*[T] = ref BinaryTreeObj[T] # type that is exported + BinaryTree*[T] = ref object # BinaryTree is a generic type with + # generic param ``T`` + le, ri: BinaryTree[T] # left and right subtrees; may be nil + data: T # the data stored in a node proc newNode*[T](data: T): BinaryTree[T] = # constructor for a node |