Returning objects from func with ARC

2020-11-07 Thread o24
I'm studying the various implementation of `get_password` in this file: # minimal.nim type Wrapper = object password: int proc `=destroy`*(self: var Wrapper) = echo "=destroy(", self.password, ")" proc `=sink`*(dest: var Wrapper, source: Wrapper) =

Forcing a memory leak in Nim

2020-10-17 Thread o24
Thanks, all. I'll go through these one by one. > Just `var mem = create int` should do. `--gc:none` memory is never freed. Using this program: var mem = create int mem = nil Run and compiling with `nim compile --gc:none leak.nim`, I still do **not** get a memory

Forcing a memory leak in Nim

2020-10-17 Thread o24
I am trying to force Nim to leak memory to better understand the memory model. >From my understanding, the following two programs are identical. #include int main() { int *x = malloc(sizeof(int)); x = 0; } Run var mem: ptr int = c

RLock compilation failure

2020-10-14 Thread o24
This is my first few hours working with Nim. On my Debian machine with Linux 5.7, the following Nim file compiles successfully: import rlocks var x: RLock x.initRLock() echo $tryAcquire(x) # prints out "true" Run but the following fails to compile: