@LeuGim It seems to me you made a type factory, actually. That's not something
I would like to see, actually. Especially considering the fact I can't add
concepts to types already in existence which is, by far, the greatest advantage
of concepts over inheritance/interfaces.
I tried something like this:
import sequtils
import macros
type
MyCon = concept type T
# line 7:
MyCon_reprs.anyIt(it.sameType(T.getType))
var MyCon_reprs {.compileTime.} = newSeq[NimNode]()
# there is no reliable comparator for NimSym, so use NimNode
proc shout(i: MyCon) =
echo "I am here!"
static:
MyCon_reprs.add(int.getType)
MyCon_reprs.add(float.getType)
echo int.getType in MyCon_Reprs # false
for el in MyCon_Reprs:
echo el, " == ", int.getType, " is ", el.sameType(int.getType)
# prints at compile-time:
# int == int is true
# float == int is false
shout(5) # XYZ.nim(7, 16) MyCon: cannot evaluate at compile time:
result112414
Which suggests me concepts aren't really integrated into the whole compile-time
environment all that well...