fork download
  1. type
  2. Data = tuple[x, y: int, s: string]
  3.  
  4. # allocate memory for Data on the heap:
  5. var d = cast[ptr Data](alloc0(sizeof(Data)))
  6.  
  7. # create a new string on the garbage collected heap:
  8. d.s = "abc"
  9.  
  10. # tell the GC that the string is not needed anymore: not sure why????
  11. GCunref(d.s)
  12.  
  13. # free the memory:
  14. dealloc(d)
Success #stdin #stdout 0s 6828KB
stdin
Standard input is empty
stdout
Standard output is empty