From f7dca91344392a200392bdbd5d2d7c5167298e93 Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 15 Nov 2014 11:10:13 +0100 Subject: [PATCH] fixes #619 --- doc/manual/procs.txt | 6 +++++- doc/manual/templates.txt | 19 +++++++++++++++++-- lib/pure/collections/sequtils.nim | 4 ++++ lib/pure/fenv.nim | 2 +- lib/system.nim | 5 ++--- todo.txt | 1 - web/download.txt | 2 +- web/news.txt | 2 +- 8 files changed, 31 insertions(+), 10 deletions(-) diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt index e03845d76..9ddae6230 100644 --- a/doc/manual/procs.txt +++ b/doc/manual/procs.txt @@ -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 ---------- diff --git a/doc/manual/templates.txt b/doc/manual/templates.txt index 4793d68a7..d90c2203e 100644 --- a/doc/manual/templates.txt +++ b/doc/manual/templates.txt @@ -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 ====== diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index b824210a5..befc9bacb 100644 --- a/lib/pure/collections/sequtils.nim +++ b/lib/pure/collections/sequtils.nim @@ -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 `_ + ## for an explanation. var result {.gensym.}: seq[type(iter)] = @[] for x in iter: add(result, x) result diff --git a/lib/pure/fenv.nim b/lib/pure/fenv.nim index 1859f7be7..415ef455e 100644 --- a/lib/pure/fenv.nim +++ b/lib/pure/fenv.nim @@ -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.} diff --git a/lib/system.nim b/lib/system.nim index 59a10f7e8..f268889d6 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -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 diff --git a/todo.txt b/todo.txt index e0d6313b3..a6ea31560 100644 --- a/todo.txt +++ b/todo.txt @@ -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 diff --git a/web/download.txt b/web/download.txt index 2d3abe3db..59ecdc3f5 100644 --- a/web/download.txt +++ b/web/download.txt @@ -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 diff --git a/web/news.txt b/web/news.txt index 7f2e3c1a8..0c3cedf35 100644 --- a/web/news.txt +++ b/web/news.txt @@ -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