标识符的构建

在模板中,标识符可以通过反引号标注构建:

  1. template typedef(name: untyped, typ: typedesc) =
  2. type
  3. `T name`* {.inject.} = typ
  4. `P name`* {.inject.} = ref `T name`
  5. typedef(myint, int)
  6. var x: PMyInt

在这个例子中, name 参数实例化为 myint,所以 `T name` 就变为 Tmyint。