tmacro3.nim 426 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. output: ""
  3. """
  4. import macros
  5. type
  6. TA = tuple[a: int]
  7. PA = ref TA
  8. macro test*(a: untyped): untyped =
  9. var val: PA
  10. new(val)
  11. val.a = 4
  12. test:
  13. "hi"
  14. macro test2*(a: untyped): untyped =
  15. proc testproc(recurse: int) =
  16. echo "That's weird"
  17. var o : NimNode = nil
  18. echo " no its not!"
  19. o = newNimNode(nnkNone)
  20. if recurse > 0:
  21. testproc(recurse - 1)
  22. testproc(5)
  23. test2:
  24. "hi"