Open moradology opened 7 years ago
The current thinking on this is to provide - via a very simple algorithm - a means of identifying nodes. This way the client and server can pass information back and forth about portions of the tree without passing indexes around in a JSON structure that we'd like to keep as thin as possible. Perhaps:
trait AST {
var id: Option[Int]
def identify(ast: AST): AST = {
var count = 0
def eval(ast: AST): AST = {
val thisId = Some(count)
count = count + 1
ast match {
case l: LeafNode =>
l.withId(thisId)
case b: BranchNode =>
val children = b.args.map(eval)
b.withId(thisId).withChildren(children)
}
}
}
In RFML, we've used
UUID
s that get associated with a node for the ID of that node. We should either trim that down (associate anInt
with a node instead) or be able to (repeatably) generate a unique set of IDs in some fashion for a given tree