diff options
-rw-r--r-- | compiler/lambdalifting.nim | 3 | ||||
-rwxr-xr-x | doc/manual.txt | 34 | ||||
-rwxr-xr-x | todo.txt | 5 | ||||
-rwxr-xr-x | web/news.txt | 1 |
4 files changed, 36 insertions, 7 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 5896615c0..925cccb72 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -692,4 +692,7 @@ Is transformed to: let i = foo(cl) if cl.state == -1: break """ + InternalAssert body.kind == nkForStmt + # gather vars in a tuple: + var L = body.len diff --git a/doc/manual.txt b/doc/manual.txt index 59ef5850a..414c43874 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2778,7 +2778,12 @@ This allows for a Lisp-like `condition system`:idx:\: var myFile = open("broken.txt", fmWrite) try: onRaise(proc (e: ref E_Base): bool = - stdout.writeln "ok, writing to stdout instead") + if e of EIO: + stdout.writeln "ok, writing to stdout instead" + else: + # do raise other exceptions: + result = true + ) myFile.writeln "writing to broken file" finally: myFile.close() @@ -2859,6 +2864,9 @@ effect is a means to *tag* a routine and perform checks against this tag: # the compiler prevents this: let x = readLine() +A tag has to be a type name. A ``tags`` list - like a ``raises`` list - can +also be attached to a proc type. This affects type compatibility. + The inference for tag tracking is analogous to the inference for exception tracking. @@ -2948,6 +2956,7 @@ Example: `type parameters`:idx:. Depending on context, the brackets are used either to introduce type parameters or to instantiate a generic proc, iterator or type. + Is operator ~~~~~~~~~~~ @@ -3084,6 +3093,8 @@ To be written. Return Type Inference ~~~~~~~~~~~~~~~~~~~~~ +**Note**: ``auto`` is not yet implemented. + If a type class is used as the return type of a proc and it won't be bound to a concrete type by some of the proc params, Nimrod will infer the return type from the proc body. This is usually used with the ``auto`` type class: @@ -3098,12 +3109,17 @@ Future versions of nimrod may also support overloading based on the return type of the overloads. In such settings, the expected result type at call sites may also influence the inferred return type. + Symbol lookup in generics ~~~~~~~~~~~~~~~~~~~~~~~~~ -Symbols in generics are looked up in two different contexts: Both the context -at definition and the context at instantiation are considered for any symbol -occurring in a generic: +The symbol binding rules in generics are slightly subtle: There are "open" and +"closed" symbols. A "closed" symbol cannot be re-bound in the instantiation +context, an "open" symbol can be. Per default overloaded symbols are open +and every other symbol is closed. + +Open symbols are looked up in two different contexts: Both the context +at definition and the context at instantiation are considered: .. code-block:: nimrod type @@ -3122,6 +3138,16 @@ the ``TIndex`` type is defined *after* the ``==`` for tuples; yet the example compiles as the instantiation takes the currently defined symbols into account too. +A symbol can be forced to be open by a `mixin`:idx: declaration: + +.. code-block:: nimrod + proc create*[T](): ref T = + # there is no overloaded 'mixin' here, so we need to state that it's an + # open symbol explicitly: + mixin init + new result + init result + Templates --------- diff --git a/todo.txt b/todo.txt index 90d3aaad0..e6a73a913 100755 --- a/todo.txt +++ b/todo.txt @@ -11,11 +11,10 @@ version 0.9.2 - ``hoist`` pragma for loop hoisting: can be easily done with AST overloading + global -- document 'mixin' for generics and symbol lookup rules; special rule - for ``[]=`` - implement the compiler as a service - ``=`` should be overloadable; requires specialization for ``=`` -- make 'bind' default for templates and introduce 'mixin' +- make 'bind' default for templates and introduce 'mixin'; + special rule for ``[]=`` - implicit deref for parameter matching; overloading based on 'var T' - optimize genericAssign in the code generator diff --git a/web/news.txt b/web/news.txt index 2dcf3f913..9101f8974 100755 --- a/web/news.txt +++ b/web/news.txt @@ -35,6 +35,7 @@ Language Additions - Table constructors now mimic more closely the syntax of the ``case`` statement. - Nimrod can now infer the return type of a proc from its body. +- Added a ``mixin`` declaration to affect symbol binding rules in generics. - Exception tracking has been added and the ``doc2`` command annotates possible exceptions for you. |