Closed gelisam closed 1 year ago
I've figured it out: SetValue()
is needed by StmtRes
and friends, because it needs to use the latest value in order to run its side-effects, but it doesn't have access to the engine's table of cached values.
As a quick aside, I've been writing the new version of the engine to not use SetValue, and instead have obj.table be returned via a Table() method... Having said that, I'm still hitting some bugs that is blocking this from happening, and I'm not yet sure why. I guess this PR was prescient! ... If I can end up making it work that is!
The method is used by the function engine to store the latest value which was emitted by
Func::Stream()
, but this is redundant because the engine also stores that value in the engine's owntable[vertex]
.Moreover, most of the
SetValue()
implementations have a comment indicating that the function is a no-op, or is never called and is only implemented for consistency.Expr::Value()
is still useful because it is used during unification. For example,printf("%d", x)
can tell the type checker thatx
must be anint
, but only if the format argument's value is statically known. So it is still useful to have a method for asking for that value if it is known.