mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 21:17:48 +00:00
use lower-case proc names
This commit is contained in:
@@ -91,7 +91,7 @@ proc toNode(t: PType, i: TLineInfo): PNode =
|
||||
|
||||
const
|
||||
# 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`
|
||||
tyUserDefinedGenerics* = {tyGenericInst, tyGenericInvocation,
|
||||
tyUserTypeClassInst}
|
||||
@@ -120,15 +120,15 @@ proc evalTypeTrait(trait: PNode, operand: PType, context: PSym): PNode =
|
||||
result = newIntNode(nkIntLit, typ.len - ord(typ.kind==tyProc))
|
||||
result.typ = newType(tyInt, context)
|
||||
result.info = trait.info
|
||||
of "GenericHead":
|
||||
of "genericHead":
|
||||
var res = uninstantiate(typ)
|
||||
if res == typ and res.kind notin tyMagicGenerics:
|
||||
localError(trait.info,
|
||||
"GenericHead expects a generic type. The given type was " &
|
||||
"genericHead expects a generic type. The given type was " &
|
||||
typeToString(typ))
|
||||
return newType(tyError, context).toNode(trait.info)
|
||||
result = res.base.toNode(trait.info)
|
||||
of "StripGenericParams":
|
||||
of "stripGenericParams":
|
||||
result = uninstantiate(typ).toNode(trait.info)
|
||||
else:
|
||||
internalAssert false
|
||||
|
||||
@@ -317,7 +317,7 @@ The concept types can be parametric just like the regular generic types:
|
||||
m[int, int] is 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]
|
||||
|
||||
|
||||
@@ -34,18 +34,18 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
|
||||
proc arity*(t: typedesc): int {.magic: "TypeTrait".}
|
||||
## 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
|
||||
## uninstantiated form.
|
||||
##
|
||||
## For example:
|
||||
## seq[int].GenericHead will be just seq
|
||||
## seq[int].GenericHead[float] will be seq[float]
|
||||
## seq[int].genericHead will be just seq
|
||||
## seq[int].genericHead[float] will be seq[float]
|
||||
##
|
||||
## A compile-time error will be produced if the supplied type
|
||||
## is not generic
|
||||
|
||||
proc StripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
||||
## This trait is similar to `GenericHead`, but instead of producing
|
||||
proc stripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".}
|
||||
## This trait is similar to `genericHead`, but instead of producing
|
||||
## error for non-generic types, it will just return them unmodified
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ type
|
||||
m[int, int] is 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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user