diff options
author | Araq <rumpf_a@web.de> | 2013-08-30 12:44:27 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-08-30 12:44:27 +0200 |
commit | 8710118b2cb1428a6ddb7929edaeef060f360be9 (patch) | |
tree | 96772e55b0e6bb92c70044083bbb9db4d9918f13 /lib/system.nim | |
parent | a17076cf4fdfb27ee1d1f3be232b81584a99432a (diff) | |
parent | c934a33ccd85716b66d44bca6a1764204507f33e (diff) | |
download | Nim-8710118b2cb1428a6ddb7929edaeef060f360be9.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/system.nim b/lib/system.nim index 98c79de5f..40a9be2d4 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -54,7 +54,7 @@ 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) - typeDesc* {.magic: TypeDesc.} ## meta type to denote a type description + typedesc* {.magic: TypeDesc.} ## meta type to denote a type description void* {.magic: "VoidType".} ## meta type to denote the absense of any type auto* = expr any* = distinct auto @@ -78,6 +78,17 @@ type TNumber* = TInteger|TReal ## type class matching all number types +type + ## helper types for writing implicitly generic procs + T1* = expr + T2* = expr + T3* = expr + T4* = expr + T5* = expr + type1* = typedesc + type2* = typedesc + type3* = typedesc + proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.} ## Special compile-time procedure that checks whether `x` is ## defined. `x` has to be an identifier or a qualified identifier. @@ -1487,7 +1498,7 @@ when not defined(NimrodVM): proc seqToPtr[T](x: seq[T]): pointer {.noStackFrame, nosideeffect.} = asm """return `x`""" - proc `==` *[T: typeDesc](x, y: seq[T]): bool {.noSideEffect.} = + proc `==` *[T](x, y: seq[T]): bool {.noSideEffect.} = ## Generic equals operator for sequences: relies on a equals operator for ## the element type `T`. if seqToPtr(x) == seqToPtr(y): @@ -1499,7 +1510,7 @@ when not defined(NimrodVM): if x[i] != y[i]: return false result = true -proc find*[T, S: typeDesc](a: T, item: S): int {.inline.}= +proc find*[T, S](a: T, item: S): int {.inline.}= ## Returns the first index of `item` in `a` or -1 if not found. This requires ## appropriate `items` and `==` operations to work. for i in items(a): @@ -1802,7 +1813,7 @@ proc debugEcho*[T](x: varargs[T, `$`]) {.magic: "Echo", noSideEffect, ## to be free of side effects, so that it can be used for debugging routines ## marked as ``noSideEffect``. -template newException*(exceptn: typeDesc, message: string): expr = +template newException*(exceptn: typedesc, message: string): expr = ## creates an exception object of type ``exceptn`` and sets its ``msg`` field ## to `message`. Returns the new exception object. var @@ -1815,7 +1826,7 @@ when hostOS == "standalone": include panicoverride when not defined(sysFatal): - template sysFatal(exceptn: typeDesc, message: string) = + template sysFatal(exceptn: typedesc, message: string) = when hostOS == "standalone": panic(message) else: @@ -1824,7 +1835,7 @@ when not defined(sysFatal): e.msg = message raise e - template sysFatal(exceptn: typeDesc, message, arg: string) = + template sysFatal(exceptn: typedesc, message, arg: string) = when hostOS == "standalone": rawoutput(message) panic(arg) |