t23032_1.nim 378 B

1234567891011121314151617181920
  1. import std/macros
  2. type A[T, H] = object
  3. proc `%*`(a: A): bool = true
  4. proc `%*`[T](a: A[int, T]): bool = false
  5. macro collapse(s: untyped) =
  6. result = newStmtList()
  7. result.add quote do:
  8. doAssert(`s`(A[float, int]()) == true)
  9. macro startHere(n: untyped): untyped =
  10. result = newStmtList()
  11. let s = n[0]
  12. result.add quote do:
  13. `s`.collapse()
  14. startHere(`a` %* `b`)