pragmatrix / granularity

Fine-grained incremental-computation for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement Debug for Value<T: Debug>

pragmatrix opened this issue · comments

commented

At first this sounds trivial, but T itself might not be evaluated, i.e. is currently invalid, and if so, should it be evaluated when a Debug::fmt() call is invoked, and at the time it is evaluated while the invoker runs in an evaluation context, should the reader be tracked?

This is part of the self-reflection facilities.

My gut feeling is that there might be a couple of functions needed:

  • A fmt function that is totally passive (this should probably the default Debug::fmt() implementation to prevent surprises.
  • A fmt function that tracks, but does not evaluate (how does this even work, readers can't be stored for invalid nodes?). This can be useful for real-time introspection.
  • A fmt function that evaluates and tracks. This is risky, because it significantly effects the underlying evaluation graph, but as long it is pure in the sense that the evaluation causes no side-effects, this can be useful for deep inspection.

Also there might be the need some kind of "passive" observers: values that depend on other values, but they see None when they refer to values are invalid. Problem here is that they also need to observe them using week ref counts, otherwise the observers would pin the observed to memory. And weak ref counts, aren't really completely weak in Rust, because they not only keep the reference count on the heap, but also the memory of the target object after it gets dropped. So they need regular maintenance.