summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-07-30 16:07:33 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-07-30 16:34:42 +0200
commit8876ed23f1dc6d12a8ae7bf061b7e31c3adf54b4 (patch)
tree849c2cb53e205f2fc48418f88ab9acdd783f9137
parent86d4090cd890b6159f93c455f60c5f3ef56a1d27 (diff)
downloadNim-8876ed23f1dc6d12a8ae7bf061b7e31c3adf54b4.tar.gz
expr and stmt are now deprecated
-rw-r--r--compiler/commands.nim2
-rw-r--r--compiler/options.nim12
-rw-r--r--compiler/packagehandling.nim2
-rw-r--r--doc/manual/generics.txt2
-rw-r--r--doc/manual/locking.txt6
-rw-r--r--doc/manual/pragmas.txt2
-rw-r--r--doc/manual/templates.txt26
-rw-r--r--doc/manual/trmacros.txt18
-rw-r--r--doc/manual/types.txt12
-rw-r--r--lib/posix/posix.nim2
-rw-r--r--lib/pure/algorithm.nim4
-rw-r--r--lib/pure/collections/sets.nim4
-rw-r--r--lib/pure/os.nim4
-rw-r--r--lib/system.nim6
14 files changed, 51 insertions, 51 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim
index b468dd6b8..48926f602 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -12,7 +12,7 @@
 
 # We do this here before the 'import' statement so 'defined' does not get
 # confused with 'TGCMode.gcGenerational' etc.
-template bootSwitch(name, expr, userString: expr): expr =
+template bootSwitch(name, expr, userString) =
   # Helper to build boot constants, for debugging you can 'echo' the else part.
   const name = if expr: " " & userString else: ""
 
diff --git a/compiler/options.nim b/compiler/options.nim
index dbd8ca2b9..a5154cb48 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -129,10 +129,10 @@ var
 proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools}
 proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc
 
-template compilationCachePresent*: expr =
+template compilationCachePresent*: untyped =
   {optCaasEnabled, optSymbolFiles} * gGlobalOptions != {}
 
-template optPreserveOrigSource*: expr =
+template optPreserveOrigSource*: untyped =
   optEmbedOrigSrc in gGlobalOptions
 
 const
@@ -405,10 +405,10 @@ proc binaryStrSearch*(x: openArray[string], y: string): int =
       return mid
   result = - 1
 
-template nimdbg*: expr = c.module.fileIdx == gProjectMainIdx
-template cnimdbg*: expr = p.module.module.fileIdx == gProjectMainIdx
-template pnimdbg*: expr = p.lex.fileIdx == gProjectMainIdx
-template lnimdbg*: expr = L.fileIdx == gProjectMainIdx
+template nimdbg*: untyped = c.module.fileIdx == gProjectMainIdx
+template cnimdbg*: untyped = p.module.module.fileIdx == gProjectMainIdx
+template pnimdbg*: untyped = p.lex.fileIdx == gProjectMainIdx
+template lnimdbg*: untyped = L.fileIdx == gProjectMainIdx
 
 proc parseIdeCmd*(s: string): IdeCmd =
   case s:
diff --git a/compiler/packagehandling.nim b/compiler/packagehandling.nim
index c42a4d763..6a98ffe60 100644
--- a/compiler/packagehandling.nim
+++ b/compiler/packagehandling.nim
@@ -15,7 +15,7 @@ iterator myParentDirs(p: string): string =
     if current.len == 0: break
     yield current
 
-template newPackageCache(): expr =
+template newPackageCache(): untyped =
   newStringTable(when FileSystemCaseSensitive:
                    modeCaseInsensitive
                  else:
diff --git a/doc/manual/generics.txt b/doc/manual/generics.txt
index 5f22e959a..c1c6467e7 100644
--- a/doc/manual/generics.txt
+++ b/doc/manual/generics.txt
@@ -293,7 +293,7 @@ definition):
   var
     lastId = 0
 
-  template genId*: expr =
+  template genId*: untyped =
     bind lastId
     inc(lastId)
     lastId
diff --git a/doc/manual/locking.txt b/doc/manual/locking.txt
index b14c98636..c00efdd91 100644
--- a/doc/manual/locking.txt
+++ b/doc/manual/locking.txt
@@ -48,7 +48,7 @@ semantics and should not be used directly! It should only be used in templates
 that also implement some form of locking at runtime:
 
 .. code-block:: nim
-  template lock(a: TLock; body: stmt) =
+  template lock(a: TLock; body: untyped) =
     pthread_mutex_lock(a)
     {.locks: [a].}:
       try:
@@ -64,7 +64,7 @@ model low level lockfree mechanisms:
   var dummyLock {.compileTime.}: int
   var atomicCounter {.guard: dummyLock.}: int
 
-  template atomicRead(x): expr =
+  template atomicRead(x): untyped =
     {.locks: [dummyLock].}:
       memoryReadBarrier()
       x
@@ -167,7 +167,7 @@ the runtime check is required to ensure a global ordering for two locks ``a``
 and ``b`` of the same lock level:
 
 .. code-block:: nim
-  template multilock(a, b: ptr TLock; body: stmt) =
+  template multilock(a, b: ptr TLock; body: untyped) =
     if cast[ByteAddress](a) < cast[ByteAddress](b):
       pthread_mutex_lock(a)
       pthread_mutex_lock(b)
diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt
index 88ddabef8..70fc4a914 100644
--- a/doc/manual/pragmas.txt
+++ b/doc/manual/pragmas.txt
@@ -213,7 +213,7 @@ statement as seen in stack backtraces:
 
 .. code-block:: nim
 
-  template myassert*(cond: expr, msg = "") =
+  template myassert*(cond: untyped, msg = "") =
     if not cond:
       # change run-time line information of the 'raise' statement:
       {.line: InstantiationInfo().}:
diff --git a/doc/manual/templates.txt b/doc/manual/templates.txt
index b60fe632e..be5c6fa18 100644
--- a/doc/manual/templates.txt
+++ b/doc/manual/templates.txt
@@ -57,8 +57,7 @@ A template where every parameter is ``untyped`` is called an `immediate`:idx:
 template. For historical reasons templates can be explicitly annotated with
 an ``immediate`` pragma and then these templates do not take part in
 overloading resolution and the parameters' types are *ignored* by the
-compiler. Explicit immediate templates are about to be deprecated in later
-versions of the compiler.
+compiler. Explicit immediate templates are now deprecated.
 
 **Note**: For historical reasons ``stmt`` is an alias for ``typed`` and
 ``expr`` an alias for ``untyped``, but new code should use the newer,
@@ -159,7 +158,7 @@ bound from the definition scope of the template:
   var
     lastId = 0
 
-  template genId*: expr =
+  template genId*: untyped =
     inc(lastId)
     lastId
 
@@ -181,7 +180,7 @@ In templates identifiers can be constructed with the backticks notation:
 
 .. code-block:: nim
 
-  template typedef(name: expr, typ: typedesc) {.immediate.} =
+  template typedef(name: untyped, typ: typedesc) =
     type
       `T name`* {.inject.} = typ
       `P name`* {.inject.} = ref `T name`
@@ -242,7 +241,7 @@ template cannot be accessed in the instantiation context:
 
 .. code-block:: nim
 
-  template newException*(exceptn: typedesc, message: string): expr =
+  template newException*(exceptn: typedesc, message: string): untyped =
     var
       e: ref exceptn  # e is implicitly gensym'ed here
     new(e)
@@ -264,7 +263,7 @@ is ``gensym`` and for ``proc``, ``iterator``, ``converter``, ``template``,
 template parameter, it is an inject'ed symbol:
 
 .. code-block:: nim
-  template withFile(f, fn, mode: expr, actions: stmt): stmt {.immediate.} =
+  template withFile(f, fn, mode: untyped, actions: untyped): untyped =
     block:
       var f: File  # since 'f' is a template param, it's injected implicitly
       ...
@@ -298,7 +297,7 @@ rewritten to ``f(x)``. Therefore the dot syntax has some limiations when it
 is used to invoke templates/macros:
 
 .. code-block:: nim
-  template declareVar(name: expr): stmt =
+  template declareVar(name: untyped) =
     const name {.inject.} = 45
 
   # Doesn't compile:
@@ -325,8 +324,7 @@ Macros
 ======
 
 A macro is a special kind of low level template. Macros can be used
-to implement `domain specific languages`:idx:. Like templates, macros come in
-the 2 flavors *immediate* and *ordinary*.
+to implement `domain specific languages`:idx:.
 
 While macros enable advanced compile-time code transformations, they
 cannot change Nim's syntax. However, this is no real restriction because
@@ -351,7 +349,7 @@ variable number of arguments:
   # ``macros`` module:
   import macros
 
-  macro debug(n: varargs[expr]): stmt =
+  macro debug(n: varargs[untyped]): untyped =
     # `n` is a Nim AST that contains the whole macro invocation
     # this macro returns a list of statements:
     result = newNimNode(nnkStmtList, n)
@@ -406,7 +404,7 @@ builtin can be used for that:
 .. code-block:: nim
   import macros
 
-  macro debug(n: varargs[expr]): stmt =
+  macro debug(n: varargs[typed]): untyped =
     result = newNimNode(nnkStmtList, n)
     for i in 0..n.len-1:
       # we can bind symbols in scope via 'bindSym':
@@ -454,7 +452,7 @@ regular expressions:
 .. code-block:: nim
   import macros
 
-  macro case_token(n: stmt): stmt =
+  macro case_token(n: untyped): untyped =
     # creates a lexical analyzer from regular expressions
     # ... (implementation is an exercise for the reader :-)
     discard
@@ -486,14 +484,14 @@ Whole routines (procs, iterators etc.) can also be passed to a template or
 a macro via the pragma notation:
 
 .. code-block:: nim
-  template m(s: stmt) = discard
+  template m(s: untyped) = discard
 
   proc p() {.m.} = discard
 
 This is a simple syntactic transformation into:
 
 .. code-block:: nim
-  template m(s: stmt) = discard
+  template m(s: untyped) = discard
 
   m:
     proc p() = discard
diff --git a/doc/manual/trmacros.txt b/doc/manual/trmacros.txt
index 446896e28..0845cebf5 100644
--- a/doc/manual/trmacros.txt
+++ b/doc/manual/trmacros.txt
@@ -135,7 +135,7 @@ The ``|`` operator
 The ``|`` operator if used as infix operator creates an ordered choice:
 
 .. code-block:: nim
-  template t{0|1}(): expr = 3
+  template t{0|1}(): untyped = 3
   let a = 1
   # outputs 3:
   echo a
@@ -144,7 +144,7 @@ The matching is performed after the compiler performed some optimizations like
 constant folding, so the following does not work:
 
 .. code-block:: nim
-  template t{0|1}(): expr = 3
+  template t{0|1}(): untyped = 3
   # outputs 1:
   echo 1
 
@@ -161,7 +161,7 @@ A pattern expression can be bound to a pattern parameter via the ``expr{param}``
 notation:
 
 .. code-block:: nim
-  template t{(0|1|2){x}}(x: expr): expr = x+1
+  template t{(0|1|2){x}}(x: untyped): untyped = x+1
   let a = 1
   # outputs 2:
   echo a
@@ -173,7 +173,7 @@ The ``~`` operator
 The ``~`` operator is the **not** operator in patterns:
 
 .. code-block:: nim
-  template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt =
+  template t{x = (~x){y} and (~x){z}}(x, y, z: bool) =
     x = y
     if x: x = z
 
@@ -200,7 +200,7 @@ to ``&(a, b, c)``:
     for i in 1..len(s)-1: result.add s[i]
     inc calls
 
-  template optConc{ `&&` * a }(a: string): expr = &&a
+  template optConc{ `&&` * a }(a: string): untyped = &&a
 
   let space = " "
   echo "my" && (space & "awe" && "some " ) && "concat"
@@ -239,7 +239,7 @@ all the arguments, but also the matched operators in reverse polish notation:
   proc mat21(): Matrix =
     result.dummy = 21
 
-  macro optM{ (`+`|`-`|`*`) ** a }(a: Matrix): expr =
+  macro optM{ (`+`|`-`|`*`) ** a }(a: Matrix): untyped =
     echo treeRepr(a)
     result = newCall(bindSym"mat21")
 
@@ -273,7 +273,7 @@ parameter is of the type ``varargs`` it is treated specially and it can match
   template optWrite{
     write(f, x)
     ((write|writeLine){w})(f, y)
-  }(x, y: varargs[expr], f: File, w: expr) =
+  }(x, y: varargs[untyped], f: File, w: untyped) =
     w(f, x, y)
 
 
@@ -288,8 +288,8 @@ implemented with term rewriting:
   proc p(x, y: int; cond: bool): int =
     result = if cond: x + y else: x - y
 
-  template optP1{p(x, y, true)}(x, y: expr): expr = x + y
-  template optP2{p(x, y, false)}(x, y: expr): expr = x - y
+  template optP1{p(x, y, true)}(x, y: untyped): untyped = x + y
+  template optP2{p(x, y, false)}(x, y: untyped): untyped = x - y
 
 
 Example: Hoisting
diff --git a/doc/manual/types.txt b/doc/manual/types.txt
index 4c015ffb7..c07efb04c 100644
--- a/doc/manual/types.txt
+++ b/doc/manual/types.txt
@@ -539,12 +539,12 @@ not wrapped in another implicit array construction:
   takeV([123, 2, 1]) # takeV's T is "int", not "array of int"
 
 
-``varargs[expr]`` is treated specially: It matches a variable list of arguments
+``varargs[typed]`` is treated specially: It matches a variable list of arguments
 of arbitrary type but *always* constructs an implicit array. This is required
 so that the builtin ``echo`` proc does what is expected:
 
 .. code-block:: nim
-  proc echo*(x: varargs[expr, `$`]) {...}
+  proc echo*(x: varargs[typed, `$`]) {...}
 
   echo @[1, 2, 3]
   # prints "@[1, 2, 3]" and not "123"
@@ -1082,7 +1082,7 @@ But it seems all this boilerplate code needs to be repeated for the ``Euro``
 currency. This can be solved with templates_.
 
 .. code-block:: nim
-  template additive(typ: typedesc): stmt =
+  template additive(typ: typedesc) =
     proc `+` *(x, y: typ): typ {.borrow.}
     proc `-` *(x, y: typ): typ {.borrow.}
 
@@ -1090,18 +1090,18 @@ currency. This can be solved with templates_.
     proc `+` *(x: typ): typ {.borrow.}
     proc `-` *(x: typ): typ {.borrow.}
 
-  template multiplicative(typ, base: typedesc): stmt =
+  template multiplicative(typ, base: typedesc) =
     proc `*` *(x: typ, y: base): typ {.borrow.}
     proc `*` *(x: base, y: typ): typ {.borrow.}
     proc `div` *(x: typ, y: base): typ {.borrow.}
     proc `mod` *(x: typ, y: base): typ {.borrow.}
 
-  template comparable(typ: typedesc): stmt =
+  template comparable(typ: typedesc) =
     proc `<` * (x, y: typ): bool {.borrow.}
     proc `<=` * (x, y: typ): bool {.borrow.}
     proc `==` * (x, y: typ): bool {.borrow.}
 
-  template defineCurrency(typ, base: expr): stmt =
+  template defineCurrency(typ, base: untyped) =
     type
       typ* = distinct base
     additive(typ)
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index cd21b5c8b..bd69b2328 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -2667,7 +2667,7 @@ proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {.
 
 proc handle_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.importc: "signal", header: "<signal.h>".}
 
-template onSignal*(signals: varargs[cint], body: untyped): stmt =
+template onSignal*(signals: varargs[cint], body: untyped) =
   ## Setup code to be executed when Unix signals are received. Example:
   ## from posix import SIGINT, SIGTERM
   ## onSignal(SIGINT, SIGTERM):
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim
index c0acae138..eee4fab22 100644
--- a/lib/pure/algorithm.nim
+++ b/lib/pure/algorithm.nim
@@ -114,7 +114,7 @@ proc lowerBound*[T](a: openArray[T], key: T, cmp: proc(x,y: T): int {.closure.})
 proc lowerBound*[T](a: openArray[T], key: T): int = lowerBound(a, key, cmp[T])
 proc merge[T](a, b: var openArray[T], lo, m, hi: int,
               cmp: proc (x, y: T): int {.closure.}, order: SortOrder) =
-  template `<-` (a, b: expr) =
+  template `<-` (a, b) =
     when false:
       a = b
     elif onlySafeCode:
@@ -206,7 +206,7 @@ proc sorted*[T](a: openArray[T], cmp: proc(x, y: T): int {.closure.},
     result[i] = a[i]
   sort(result, cmp, order)
 
-template sortedByIt*(seq1, op: expr): expr =
+template sortedByIt*(seq1, op: untyped): untyped =
   ## Convenience template around the ``sorted`` proc to reduce typing.
   ##
   ## The template injects the ``it`` variable which you can use directly in an
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index da32c1950..552e41ef7 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -256,7 +256,7 @@ proc incl*[A](s: var HashSet[A], other: HashSet[A]) =
   assert other.isValid, "The set `other` needs to be initialized."
   for item in other: incl(s, item)
 
-template doWhile(a: expr, b: stmt): stmt =
+template doWhile(a, b) =
   while true:
     b
     if not a: break
@@ -371,7 +371,7 @@ proc toSet*[A](keys: openArray[A]): HashSet[A] =
   result = initSet[A](rightSize(keys.len))
   for key in items(keys): result.incl(key)
 
-template dollarImpl(): stmt {.dirty.} =
+template dollarImpl() {.dirty.} =
   result = "{"
   for key in items(s):
     if result.len > 1: result.add(", ")
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 65bbab3d4..e6ecb184e 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1502,7 +1502,7 @@ type
     lastWriteTime*: Time # Time file was last modified/written to.
     creationTime*: Time # Time file was created. Not supported on all systems!
 
-template rawToFormalFileInfo(rawInfo, formalInfo): expr =
+template rawToFormalFileInfo(rawInfo, formalInfo): untyped =
   ## Transforms the native file info structure into the one nim uses.
   ## 'rawInfo' is either a 'TBY_HANDLE_FILE_INFORMATION' structure on Windows,
   ## or a 'Stat' structure on posix
@@ -1533,7 +1533,7 @@ template rawToFormalFileInfo(rawInfo, formalInfo): expr =
 
 
   else:
-    template checkAndIncludeMode(rawMode, formalMode: expr) =
+    template checkAndIncludeMode(rawMode, formalMode: untyped) =
       if (rawInfo.st_mode and rawMode) != 0'i32:
         formalInfo.permissions.incl(formalMode)
     formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
diff --git a/lib/system.nim b/lib/system.nim
index 0c7eaea95..6a9b52d24 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -66,8 +66,10 @@ type
   `ref`* {.magic: Pointer.}[T] ## built-in generic traced pointer type
 
   `nil` {.magic: "Nil".}
-  expr* {.magic: Expr.} ## meta type to denote an expression (for templates)
-  stmt* {.magic: Stmt.} ## meta type to denote a statement (for templates)
+  expr* {.magic: Expr, deprecated.} ## meta type to denote an expression (for templates)
+                        ## **Deprecated** since version 0.15. Use ``untyped`` instead.
+  stmt* {.magic: Stmt, deprecated.} ## meta type to denote a statement (for templates)
+    ## **Deprecated** since version 0.15. Use ``typed`` instead.
   typedesc* {.magic: TypeDesc.} ## meta type to denote a type description
   void* {.magic: "VoidType".}   ## meta type to denote the absence of any type
   auto* {.magic: Expr.} ## meta type for automatic type determination