Open machaval opened 5 years ago
That works for me. Need to also consider what might happen if the user tries to update the same node twice:
{foo: 123} update {
case at .foo -> {bar: true}
case at .foo -> {bar: false}
}
In this case you can ignore the second .foo
branch, returning {foo: {bar: true}}
What should happen when there are sub branches on the update.
In my opinion this case should return
{foo: {bar:true}}
and not{foo:{bar: {sub: 123}}}
and hint a warning saying thatcase .foo.bar -> {sub: 123}
this branch is never going to be executed.I think the bottom problem is how we define the semantics of update.
a. It would go through the
expression
({foo: 123}) tree and see what branch matches and updates that node with what ever the matcher returns. This is more like a tree pattern matcher mental modelb. Think of update as a sequential update expressions where they will be executed one after the other. Like a chain
{foo: 123} update .foo with {bar: true} update .foo.bar with {sub: 123}
The way it was in my mind is more like a