Minor updates; addition of var return in procs
This commit is contained in:
parent
8c8e975bcd
commit
998f1fa67a
1 changed files with 48 additions and 0 deletions
|
|
@ -762,6 +762,10 @@ Note that either the second or third (or both) parameters above must exist,
|
||||||
as the compiler needs to know the type somehow (which it can infer from
|
as the compiler needs to know the type somehow (which it can infer from
|
||||||
the given assignment).
|
the given assignment).
|
||||||
|
|
||||||
|
This is not the same AST for all uses of ``var``. See
|
||||||
|
[Procedure declaration](http://nim-lang.org/docs/macros.html#statements-procedure-declaration)
|
||||||
|
for details.
|
||||||
|
|
||||||
Let section
|
Let section
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
@ -899,6 +903,32 @@ AST:
|
||||||
)
|
)
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
|
Mixin statement
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Concrete syntax:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
mixin x
|
||||||
|
|
||||||
|
AST:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
nnkMixinStmt(nnkIdent(!"x"))
|
||||||
|
|
||||||
|
Bind statement
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Concrete syntax:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
bind x
|
||||||
|
|
||||||
|
AST:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
nnkBindStmt(nnkIdent(!"x"))
|
||||||
|
|
||||||
Procedure declaration
|
Procedure declaration
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
@ -963,6 +993,24 @@ AST:
|
||||||
),
|
),
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
|
When a procedure uses the special ``var`` type return variable, the result
|
||||||
|
is different from that of a var section.
|
||||||
|
|
||||||
|
Concrete syntax:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
proc hello(): var int
|
||||||
|
|
||||||
|
AST:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
# ...
|
||||||
|
nnkFormalParams(
|
||||||
|
nnkVarTy(
|
||||||
|
nnkIdent(!"int")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
Iterator declaration
|
Iterator declaration
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue