nimhcr_1_1.nim 829 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. echo " 1: print me once!"
  2. import hotcodereloading
  3. let g_1* = 8 # devilish!
  4. proc f_1*(): int =
  5. var a {.global.} = 1
  6. a.inc
  7. return a
  8. # all these constructs should compile
  9. let some_glob_1 = 1
  10. echo " 1: ", some_glob_1
  11. if true:
  12. let some_glob_2 = 2
  13. echo " 1: ", some_glob_2
  14. if true:
  15. let some_glob_3 = 3
  16. echo " 1: ", some_glob_3
  17. block:
  18. let some_glob_4 = 4
  19. proc inBlock(num: int) =
  20. echo " 1: ", num
  21. inBlock(some_glob_4)
  22. var counter = 3
  23. while counter > 0:
  24. let some_glob_5 = 5
  25. echo " 1: ", some_glob_5
  26. counter.dec
  27. type
  28. Type1 = object
  29. a: int
  30. b: int
  31. var t = Type1(a: 42, b: 11)
  32. echo " 1: Type1.a:", t.a
  33. type
  34. obj = ref object
  35. dat: int
  36. str: string
  37. proc foo(): (int, obj) = (1, obj(dat: 3, str: "bar"))
  38. let (aa, bb) = foo()
  39. afterCodeReload:
  40. echo aa
  41. echo bb.str