lang: funcs: dage: Use lazy freshness check

Not sure if this would introduce a glitch or not. Does seem to work
correctly. Without this, examples/lang/datetime2.mcl don't update
properly.
This commit is contained in:
James Shubin
2025-09-09 02:47:14 -04:00
parent 790b7199ca
commit a5f89d8d7b

View File

@@ -435,10 +435,10 @@ Start:
// Node we pull from should be newer epoch than us! // Node we pull from should be newer epoch than us!
if node.epoch >= fromNode.epoch { if node.epoch >= fromNode.epoch {
if obj.Debug { //if obj.Debug {
obj.Logf("inner epoch skip: %p %v", f, f) // obj.Logf("inner epoch skip: %p %v", f, f)
//obj.Logf("inner epoch skip: NODE(%p is %d): %v FROM(%p is %d) %v", f, node.epoch, f, ff, fromNode.epoch, ff) // //obj.Logf("inner epoch skip: NODE(%p is %d): %v FROM(%p is %d) %v", f, node.epoch, f, ff, fromNode.epoch, ff)
} //}
// Don't set non-valid here because if // Don't set non-valid here because if
// we have *two* FuncValue's that both // we have *two* FuncValue's that both
// interrupt, the first one will happen, // interrupt, the first one will happen,
@@ -447,18 +447,25 @@ Start:
// when the full graph is ready here, we // when the full graph is ready here, we
// would skip because of this bool! // would skip because of this bool!
//valid = false // don't do this! //valid = false // don't do this!
continue Iterate
// The mistake in this check is that if
// *any* of the incoming edges are not
// ready, then we skip it all. But one
// may not even be built yet. So it's a
// mess. So at least for now, use the
// below "is nil" check instead.
//continue Iterate
} }
value := fromNode.result value := fromNode.result
if value == nil { if value == nil {
//if valid { // must be a programming err! //if valid { // must be a programming err!
panic(fmt.Sprintf("unexpected nil node result from: %s", ff)) //panic(fmt.Sprintf("unexpected nil node result from: %s", ff))
//} //}
// We're reading from a node which got // We're reading from a node which got
// skipped because it didn't have all of // skipped because it didn't have all of
// its edges yet. (or a programming bug) // its edges yet. (or a programming bug)
//continue Iterate continue Iterate
// The fromNode epoch check above should // The fromNode epoch check above should
// make this additional check redundant. // make this additional check redundant.
} }