tvoid.nim 513 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. discard """
  2. output: '''12
  3. empty
  4. he, no return type;
  5. abc a string
  6. ha'''
  7. """
  8. proc ReturnT[T](x: T): T =
  9. when T is void:
  10. echo "he, no return type;"
  11. else:
  12. result = x & " a string"
  13. proc nothing(x, y: void): void =
  14. echo "ha"
  15. proc callProc[T](p: proc (x: T) {.nimcall.}, x: T) =
  16. when T is void:
  17. p()
  18. else:
  19. p(x)
  20. proc intProc(x: int) =
  21. echo x
  22. proc emptyProc() =
  23. echo "empty"
  24. callProc[int](intProc, 12)
  25. callProc[void](emptyProc)
  26. ReturnT[void]()
  27. echo ReturnT[string]("abc")
  28. nothing()