diff --git a/changelog.md b/changelog.md index 9bec0c47a8f49..6d22b4ca0936e 100644 --- a/changelog.md +++ b/changelog.md @@ -50,9 +50,7 @@ - Added `sugar.collect` that does comprehension for seq/set/table collections. - Added `sugar.capture` for capturing some local loop variables when creating a closure. This is an enhanced version of `closureScope`. -- Added `typetraits.lenTuple` to get number of elements of a tuple/type tuple, - and `typetraits.get` to get the ith element of a type tuple. -- Added `typetraits.genericParams` to return a tuple of generic params from a generic instantiation +generic instantiation - Added `os.normalizePathEnd` for additional path sanitization. - Added `times.fromUnixFloat,toUnixFloat`, subsecond resolution versions of `fromUnix`,`toUnixFloat`. - Added `wrapnils` module for chains of field-access and indexing where the LHS can be nil. diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim index fd729b59eae4e..80bb13b99e413 100644 --- a/lib/pure/typetraits.nim +++ b/lib/pure/typetraits.nim @@ -14,8 +14,6 @@ export system.`$` # for backward compatibility -include "system/inclrtl" - proc name*(t: typedesc): string {.magic: "TypeTrait".} ## Returns the name of the given type. ## @@ -71,46 +69,6 @@ proc distinctBase*(T: typedesc): typedesc {.magic: "TypeTrait".} ## Returns base type for distinct types, works only for distinct types. ## compile time error otherwise -import std/macros - -macro lenTuple*(t: tuple): int {.since: (1, 1).} = - ## Return number of elements of `t` - newLit t.len - -macro lenTuple*(t: typedesc[tuple]): int {.since: (1, 1).} = - ## Return number of elements of `T` - newLit t.len - -since (1, 1): - template get*(T: typedesc[tuple], i: static int): untyped = - ## Return `i`th element of `T` - # Note: `[]` currently gives: `Error: no generic parameters allowed for ...` - type(default(T)[i]) - -macro genericParams*(T: typedesc): untyped {.since: (1, 1).} = - ## return tuple of generic params for generic `T` - runnableExamples: - type Foo[T1, T2]=object - doAssert genericParams(Foo[float, string]) is (float, string) - result = newNimNode(nnkTupleConstr) - var impl = getTypeImpl(T) - expectKind(impl, nnkBracketExpr) - impl = impl[1] - while true: - case impl.kind - of nnkSym: - impl = impl.getImpl - continue - of nnkTypeDef: - impl = impl[2] - continue - of nnkBracketExpr: - for i in 1..