Open andreasplesch opened 6 years ago
yes, exactly the same is possible in spreadsheets. although sheets report an error instead of continuously updating.
On 11/22/2017 06:26 PM, Andreas Plesch wrote:
It is possible to (inadvertently) construct expressions which will never stop updating each other.
|
<loop property='b' mv-value='a+1'> | Here is a live example: https://faithful-trumpet.glitch.me/ the looped properties are shown next to the transparency slider.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mavoweb/mavo/issues/312, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFpXnVeeoKGEoyLHYVY26KW6VdrPKcSks5s5K23gaJpZM4QoHiz.
Reporting an error (perhaps the offending expression itself) would be great but loop detection may be hard ?
Yeah, this is a known issue, though I can't find an open bug report so I guess this one will have to be it.
The main issue is that it's hard to be 100% sure about what refers to what in the general case, since expressions could even contain arbitrary JS. We do currently match on identifiers used and use that to update the expression, but it's not precise (we err on the side of updating often).
I wonder if we can use a combination of criteria: both long chains of updates, and lists of identifiers. OTOH, note that this "loop" doesn't actually make anything hang, so I'm not sure it's a bug at all. One could write loops with JS as well. At least it's showing you what you've done, which a #REF! error message doesn't really.
One strategy to avoid such loops is to keep track of update cascades and only evaluate once per cascade.
If I'm understand your suggestion correctly, there are perfectly valid cases where we need to evaluate multiple times, e.g. because there is a long chain of properties referring to each other without actually causing a cycle.
That's still just one update if you update in topological order (which is also important for efficiency)
On Nov 22, 2017, 8:43 PM, at 8:43 PM, Lea Verou notifications@github.com wrote:
Yeah, this is a known issue, though I can't find an open bug report so I guess this one will have to be it.
The main issue is that it's hard to be 100% sure about what refers to what in the general case, since expressions could even contain arbitrary JS. We do currently match on identifiers used and use that to update the expression, but it's not precise (we err on the side of updating often).
I wonder if we can use a combination of criteria: both long chains of updates, and lists of identifiers. OTOH, note that this "loop" doesn't actually make anything hang, so I'm not sure it's a bug at all. One could write loops with JS as well. At least it's showing you what you've done, which a #REF! error message doesn't really.
One strategy to avoid such loops is to keep track of update cascades and only evaluate once per cascade.
If I'm understand your suggestion correctly, there are perfectly valid cases where we need to evaluate multiple times, e.g. because there is a long chain of properties referring to each other without actually causing a cycle.
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/mavoweb/mavo/issues/312#issuecomment-346515773
There must be some dampening or rate limiting happening to slow down the "looping" and avoid hanging, perhaps intended to address this situation.
So not strictly a bug and ultimately the author's responsibility and therefore probably not a priority to address. But more complicated loops may be hard to diagnose manually and so any help or safeguard would be quite useful.
A cascade starts with some update and gets an id or timestamp. The property update propagates to all expressions which use the property, and the expressions are evaluated and marked with the cascade id or timestamp. If the expression was already marked, skip it. Update properties if any and repeat until no new properties need to be updated. The cascade ends.
Something like that and probably only dealing with mavoscript. But overall may be not feasible/worthwhile and would prevent finite loops as well. If finite loops are often needed for Mavo purposes is another question.
I may prefer "cascade" over "chain" since it emphasizes that a single property update can trigger updates of multiple properties.
Let me close this issue. It could be reopened or referred to once there is an actual problem with a site.
We typically keep issues open until they’re fixed.
Ok, thanks.
It is possible to (inadvertently) construct expressions which will never stop updating each other:
Here is a live example: https://time-spleen.glitch.me/ Such infinite loops are likely never intended. One strategy to avoid such loops is to keep track of update cascades and only evaluate once per cascade. This is the rule VRML (X3D) uses to break loops.