Here is a piece of code that bugs me a bit :
x : nil A : on _ do x : x + 1 end # A stores a global variables and do a operation on # it here it is a increment A[] # 1 A[] # 2 # Here I was expected to copy the value # of A inside of B without any side effect B : A B[] # 3 B[] # 4 # B seems to work normally A[] # 5 ?? I was expecting here 3 A[] # 6
Here, I understand that now A and B share a common reference to the global variable x.
By doing something like this to create the function inside of A we can even make the global variable hidden from the outer scope :
on f x do
on _ do
x : x + 1
end
end
A : f[0]
B : A
x # is nil not accessible
A[] # 1
B[] # 2
A[] # 3
B[] # 4
Reading about Lil I thought that the "graph" of pointers inside the program was very simple because everything is a value and everything is copied. However, if it is possible to store hidden information inside the function I might have not understood something. Is this normal behavior ?
