Charles-Johnson / zia_programming

A language that can program itself
https://zia-lang.org
GNU General Public License v3.0
3 stars 0 forks source link

Reduce number of methods that mutate `Context` to achieve atomic transactions. #1

Closed Charles-Johnson closed 5 years ago

Charles-Johnson commented 5 years ago

If the interpreter panics or encounters an error after mutating part of the Context but still needs to complete more mutations, this may leave the Context in an inconsistent state. Instead of mutating as I go, I can compute what Concepts need to be mutated and describe the changes as a Delta type. The execute method can use the Delta to mutate the Context all in one place.

Context methods other than execute with a type signature like

fn mutate_something(&mut self, ... ) -> ZiaResult<()>;

can be restructured to

fn describe_what_would_mutate(&self, Delta, ...) -> ZiaResult<Delta>;

This will allow the codebase to be a lot more functional and therefore easier to reason about and spread across threads in the future. If I leave this until the future, this will require a lot more restructuring.

Charles-Johnson commented 5 years ago

Solved in #6