use lower-case proc names

This commit is contained in:
Zahary Karadjov 2017-01-27 01:21:35 +02:00
commit 9574d318ae
4 changed files with 11 additions and 11 deletions

View file

@ -91,7 +91,7 @@ proc toNode(t: PType, i: TLineInfo): PNode =
const const
# these are types that use the bracket syntax for instantiation # these are types that use the bracket syntax for instantiation
# they can be subjected to the type traits `GenericHead` and # they can be subjected to the type traits `genericHead` and
# `Uninstantiated` # `Uninstantiated`
tyUserDefinedGenerics* = {tyGenericInst, tyGenericInvocation, tyUserDefinedGenerics* = {tyGenericInst, tyGenericInvocation,
tyUserTypeClassInst} tyUserTypeClassInst}
@ -120,15 +120,15 @@ proc evalTypeTrait(trait: PNode, operand: PType, context: PSym): PNode =
result = newIntNode(nkIntLit, typ.len - ord(typ.kind==tyProc)) result = newIntNode(nkIntLit, typ.len - ord(typ.kind==tyProc))
result.typ = newType(tyInt, context) result.typ = newType(tyInt, context)
result.info = trait.info result.info = trait.info
of "GenericHead": of "genericHead":
var res = uninstantiate(typ) var res = uninstantiate(typ)
if res == typ and res.kind notin tyMagicGenerics: if res == typ and res.kind notin tyMagicGenerics:
localError(trait.info, localError(trait.info,
"GenericHead expects a generic type. The given type was " & "genericHead expects a generic type. The given type was " &
typeToString(typ)) typeToString(typ))
return newType(tyError, context).toNode(trait.info) return newType(tyError, context).toNode(trait.info)
result = res.base.toNode(trait.info) result = res.base.toNode(trait.info)
of "StripGenericParams": of "stripGenericParams":
result = uninstantiate(typ).toNode(trait.info) result = uninstantiate(typ).toNode(trait.info)
else: else:
internalAssert false internalAssert false

View file

@ -317,7 +317,7 @@ The concept types can be parametric just like the regular generic types:
m[int, int] is T m[int, int] is T
mvar[int, int] = T mvar[int, int] = T
type TransposedType = StripGenericParams(M)[C, R, T] type TransposedType = stripGenericParams(M)[C, R, T]
AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T] AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T]

View file

@ -34,18 +34,18 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
proc arity*(t: typedesc): int {.magic: "TypeTrait".} proc arity*(t: typedesc): int {.magic: "TypeTrait".}
## Returns the arity of the given type ## Returns the arity of the given type
proc GenericHead*(t: typedesc): typedesc {.magic: "TypeTrait".} proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".}
## Accepts an instantiated generic type and returns its ## Accepts an instantiated generic type and returns its
## uninstantiated form. ## uninstantiated form.
## ##
## For example: ## For example:
## seq[int].GenericHead will be just seq ## seq[int].genericHead will be just seq
## seq[int].GenericHead[float] will be seq[float] ## seq[int].genericHead[float] will be seq[float]
## ##
## A compile-time error will be produced if the supplied type ## A compile-time error will be produced if the supplied type
## is not generic ## is not generic
proc StripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".} proc stripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".}
## This trait is similar to `GenericHead`, but instead of producing ## This trait is similar to `genericHead`, but instead of producing
## error for non-generic types, it will just return them unmodified ## error for non-generic types, it will just return them unmodified

View file

@ -9,7 +9,7 @@ type
m[int, int] is T m[int, int] is T
mvar[int, int] = T mvar[int, int] = T
type TransposedType = StripGenericParams(M)[C, R, T] type TransposedType = stripGenericParams(M)[C, R, T]
AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T] AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T]