tree-il is a type and it's used by the Guile compiler
it's an intermediate language, substantially
The product of the first pass of compilation is made of such tree-il records
tree-il records are regular scheme records, nothig special
the values produced by the first pass of the compilation are trees
in which the nodes are these tree-il records
In Guile there's a procedure to visit a tree made of tree-il records.
It visit the tree depth first
and it' s a fold procedure along the lines of the fold functions that the Guile manual discusses about SXML transforming
I can't find the link now because the Guile manual is so counterintuitive that any research in it is a punishment
in simple words, when a child node gets visited, that's a recursion step and in such step
the visited child node gets passed to a "down" procedure that you have to provide yourself
together with an "accumulator" value that is the result of previous recursion steps
When the leaf of a branch gets reached, the procedure steps up again, along the same branch.
And when it steps back on a node that was already visited when going down along the branch,
the node gets passed as an argument to an "up" procedure that you're supposed to provide yourself
Together with the accumulator, that's the same accumulator as before
WHAT I WANT TO DO
I'd like to build a tree that has the exact same shape of the tree made of tree-il records
BUT I want my tree to be made of cons cells and vectors. No more
So lists, alists and vectors.
But no more.
Don't ask me why. Please take the problem I'm posing as good
When going _down_ along a branch, I konw what to do
I can add the visited node as a child of the previously visite dnode
The problem is when stepping _up_
Because in the accumulator I think I should track the fact that the visiting process is currently
on a node that is a step up in regard to the previous visiting step
Shouldn't I ?
I don't know how to do this
Clojure maps are immutable so a new map would be created at every recursion step
But behind the curtains, the structure gets not replicated as a whole, but rather versioned
and the new versions share some memory with the previous ones
This is what happens with vanilla list processing in scheme
How do I replicate a tree-il based tree in vanilla cons cells ?
maybe I should take a look at lenses ?
I still didn't study them
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!