This commit is contained in:
Araq
2014-11-15 11:10:13 +01:00
parent 9e00d3aec2
commit f7dca91344
8 changed files with 31 additions and 10 deletions

View File

@@ -84,7 +84,9 @@ current module:
var exportedVar*: int
const exportedConst* = 78
type ExportedType* = distinct int
type
ExportedType* = object
exportedField*: int
Method call syntax
@@ -107,6 +109,8 @@ to supply any type of first argument for procedures:
Another way to look at the method call syntax is that it provides the missing
postfix notation.
See also: `Limitations of the method call syntax`_.
Properties
----------

View File

@@ -225,8 +225,8 @@ a template. ``inject`` and ``gensym`` have no effect in ``dirty`` templates.
Limitations of the method invokation syntax
-------------------------------------------
Limitations of the method call syntax
-------------------------------------
The expression ``x`` in ``x.f`` needs to be semantically checked (that means
symbol lookup and type checking) before it can be decided that it needs to be
@@ -241,6 +241,21 @@ is used to invoke templates/macros:
unknownIdentifier.declareVar
Another common example is this:
.. code-block:: nim
from sequtils import toSeq
iterator something: string =
yield "Hello"
yield "World"
var info = something().toSeq()
The problem here is that the compiler already decided that ``something()`` as
an iterator is not callable in this context before ``toSeq`` gets its
chance to convert it into a sequence.
Macros
======

View File

@@ -302,6 +302,10 @@ template toSeq*(iter: expr): expr {.immediate.} =
## result = true)
## assert odd_numbers == @[1, 3, 5, 7, 9]
##
## **Note**: Since this is an immediate macro, you cannot always invoke this
## as ``x.toSeq``, depending on the ``x``.
## See `this <manual.html#limitations-of-the-method-call-syntax>`_
## for an explanation.
var result {.gensym.}: seq[type(iter)] = @[]
for x in iter: add(result, x)
result

View File

@@ -8,7 +8,7 @@
#
## Floating-point environment. Handling of floating-point rounding and
## exceptions (overflow, zero-devide, etc.).
## exceptions (overflow, division by zero, etc.).
{.deadCodeElim:on.}

View File

@@ -904,9 +904,8 @@ proc `of` *[T, S](x: T, y: S): bool {.magic: "Of", noSideEffect.}
## Checks if `x` has a type of `y`
##
## .. code-block:: Nim
## assert(EFloatingPoint of EBase)
## assert(EIO of ESystem)
## assert(EDivByZero of EBase)
## assert(FloatingPointError of Exception)
## assert(DivByZeroError of Exception)
proc cmp*[T](x, y: T): int {.procvar.} =
## Generic compare proc. Returns a value < 0 iff x < y, a value > 0 iff x > y

View File

@@ -1,7 +1,6 @@
version 0.10
============
showstopper: Nim does not boot with --threads:on!
- make nimble part of the distribution
- implement 'procCall'
- split idetools into separate tool

View File

@@ -40,7 +40,7 @@ Change the branch to suit your needs::
git clone -b master git://github.com/Araq/Nimrod.git
cd Nimrod
git clone --depth 1 git://github.com/nimrod-code/csources
git clone -b master --depth 1 git://github.com/nimrod-code/csources
cd csources && sh build.sh
cd ..
bin/nimrod c koch

View File

@@ -67,7 +67,7 @@ News
-----------------
- Added module ``fenv`` to control the handling of floating-point rounding and
exceptions (overflow, zero-devide, etc.).
exceptions (overflow, division by zero, etc.).
2014-10-19 Nimrod version 0.9.6 released