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 ?
Yes, this is normal behaviour - like a lot of functional languages, Lil has closures. The Lil docs say:
Lil uses lexical scope: variables will resolve to the closest nested binding available, and the local variables of a caller to a function will not be visible or modified by the callee (unless the callee’s definition is nested in the caller)…
Furthermore, functions close over variables in their lexical scope, allowing for encapsulated “objects” with their own mutable state
It even gives an example of putting x : x + 1 inside a nested function so you can make a counter, as you did in your second example.