On Thursday, 12 October 2017 at 02:18:49 UTC, Mr. Jonse wrote:
A simple(incomplete) undo system.
I'd think that for D you'd want to do type wrapping where a new
type is created which saves changes and can manage an Undo tree.
__gshared Data data = new Data();
auto undoable = Undo!data
undoable.x = 5;
assert(data.x == 5);
undoable.undo();
assert(data.x == 0);
undoable.redo();
assert(data.x == 5);
This would be done by monitoring the members which contain
storage, available with:
https://dlang.org/phobos/std_traits.html#Fields
This is of course specific to a single object and plan for
handling order across multiple objects along with creating an
"Edit" where many data points could change and be undone with a
single undo.