I must have been tired when I wrote this code. I am pretty certain that I
understand how the indirection works now. I just remember thinking that it was
super weird that I could change something and then another variable suddenly
changed its contents. But of course they pointed to the same
Consider the following code to create linked list-like structure:
type
A = ref AObj
AObj = object
id: int
parent: A
child: A
proc `$`(a: A): string = $a.id
proc takeAsVar(curr: var A, next: A) =
if curr == nil:
@Fungi: Scala and Haskell are both compiled languages that have REPLs. But I
can only speculate how they got it to work.