summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-04-11 21:42:28 +0200
committerAraq <rumpf_a@web.de>2011-04-11 21:42:28 +0200
commit3d696c3da53e5c41d839d8265fbc94f1c64980bb (patch)
tree4e9160d62abb1d847eb60730038ab74d5bbff995 /doc
parentfc6cc79273f75983e57c43c2a19016e5881ee2b7 (diff)
downloadNim-3d696c3da53e5c41d839d8265fbc94f1c64980bb.tar.gz
p[] instead of p^
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/manual.txt14
-rwxr-xr-xdoc/tut1.txt9
2 files changed, 14 insertions, 9 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index 92ae2cae6..f9c1fe333 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -932,8 +932,9 @@ untraced references are *unsafe*. However for certain low-level operations
 Traced references are declared with the **ref** keyword, untraced references

 are declared with the **ptr** keyword.

 

-The ``^`` operator can be used to derefer a reference, the ``addr`` procedure

-returns the address of an item. An address is always an untraced reference.

+An empty subscript ``[]`` notation can be used to derefer a reference, 

+the ``addr`` procedure returns the address of an item. An address is always 

+an untraced reference.

 Thus the usage of ``addr`` is an *unsafe* feature.

 

 The ``.`` (access a tuple/object field operator)

@@ -951,7 +952,8 @@ dereferencing operations for reference types:
   var

     n: PNode

   new(n)

-  n.data = 9 # no need to write n^ .data

+  n.data = 9 

+  # no need to write n[].data; in fact n[].data is highly discouraged!

 

 To allocate a new traced object, the built-in procedure ``new`` has to be used.

 To deal with untraced memory, the procedures ``alloc``, ``dealloc`` and

@@ -1941,8 +1943,8 @@ above example is equivalent to:
 .. code-block:: nimrod

   proc divmod(a, b: int,

               res, remainder: ptr int) =

-    res^ = a div b

-    remainder^ = a mod b

+    res[] = a div b

+    remainder[] = a mod b

 

   var

     x, y: int

@@ -2070,6 +2072,7 @@ The `for`:idx: statement is an abstract mechanism to iterate over the elements
 of a container. It relies on an `iterator`:idx: to do so. Like ``while``

 statements, ``for`` statements open an `implicit block`:idx:, so that they

 can be left with a ``break`` statement. The ``for`` loop declares

+

 iteration variables (``x`` in the example) - their scope reaches until the

 end of the loop body. The iteration variables' types are inferred by the

 return type of the iterator.

@@ -2581,6 +2584,7 @@ The `procvar`:idx: pragma is used to mark a proc that it can be passed to a
 procedural variable.

 

 

+

 compileTime pragma

 ------------------

 The `compileTime`:idx: pragma is used to mark a proc to be used at compile

diff --git a/doc/tut1.txt b/doc/tut1.txt
index 4fc8c8955..fa0fe3eee 100755
--- a/doc/tut1.txt
+++ b/doc/tut1.txt
@@ -1183,9 +1183,9 @@ untraced references are *unsafe*. However for certain low-level operations
 Traced references are declared with the **ref** keyword, untraced references
 are declared with the **ptr** keyword.
 
-The ``^`` operator can be used to *derefer* a reference, meaning to retrieve
-the item the reference points to. The ``addr`` procedure returns the address
-of an item. An address is always an untraced reference:
+The empty ``[]`` subscript notation can be used to *derefer* a reference, 
+meaning to retrieve the item the reference points to. The ``addr`` procedure 
+returns the address of an item. An address is always an untraced reference:
 ``addr`` is an *unsafe* feature.
 
 The ``.`` (access a tuple/object field operator)
@@ -1200,7 +1200,8 @@ dereferencing operations for reference types:
   var
     n: PNode
   new(n)
-  n.data = 9 # no need to write n^ .data
+  n.data = 9 
+  # no need to write n[].data; in fact n[].data is highly discouraged!
 
 (As a convention, reference types use a 'P' prefix.)