Yesterday I read
https://nim-lang.org/araq/destructors.html
Was some fun, but I still have no idea what the second line in
proc `=destroy`(x: var T) =
lazyDestroy cast[pointer](x), proc (p: pointer) =
let x = cast[var T](p)
`=destroy`(x.le)
`=destroy`(x.ri)
dealloc(p)
really is. Looks like a proc call without parenthesis, but with a equal sign at line end? No idea currently.
Well, maybe a typo, as there is at least one typo in that document:
proc add*(s: var string; c: char) =
if s.len >= s.cap: resize(s)
s.data[s.len] = c
Final inc(s.len) is missing.
@Stefan_Salewski, to further clarify, you could replace that code with the equivalent:
proc onDestroy(p: pointer) =
let x = cast[var T](p)
`=destroy`(x.le)
`=destroy`(x.ri)
dealloc(p)
proc `=destroy`(x: var T) =
lazyDestroy(cast[pointer](x), onDestroy)
I bet he only forgot about that.
I usually limit myself of not using parenthesis when the proc only need one argument, while when writing anonymous proc in parenthesis entirely e.g. (proc....), thankfully it didn't parsed as a single element tuple, (or did it? :/ )