Open enomado opened 1 year ago
@enomado I believe the panic is the expected behavior of Salsa, as mentioned in issue #407. The issue lies in the code p.md(&db)
within the loop, which continues to use a tracked struct after altering the inputs using a.set_md(&mut db).to(vec![i as f64])
. To fix this, you should call m_merge
again to get the newest tracked struct.
let a = MyVal::new(&db, vec![1.0]);
let b = MyVal::new(&db, vec![2.0]);
let p = m_merge(&db, a, b);
for i in 0..10 {
a.set_md(&mut db).to(vec![i as f64]);
let p = m_merge(&db, a, b);
dbg!(p.md(&db));
}
However, I think that the error message needs improvement to avoid confusion. A panic message like "accessing a field of a tracked struct MyVal
from an older revision" would be better.
@xffxff thanks! I thought tracked structure can store whole computation chain at its own. I think it must be covered in documentation. just like
dont expect tracked struct can recalculate itself without calling whole chain
it could clarify a lot :)
Btw, please, tell where I wrong. I want generalize input structs and tracked structs
Hi. Trying to iterate like
All code, except Database(its from example) - https://gist.github.com/enomado/92170cf942e5dc1b00b6a5f439ff7047