Design reverse write-back planning alongside forward traversal #48
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#48
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue #45 reuses the chunks created during forward traversal to perform mutation during write-back. For example, the planner might produce:
MPath then uses the
/A/Bchunk both to retrieve its selected output and to write the modified output back. The planner currently only considers retrieval usingmatlab.indexing.IndexingContext.Expression, while ignoringmatlab.indexing.IndexingContext.Assignmentin mutation operations.The current implementation essentially assumes:
listLengthbehaves consistently in both indexing contexts.parent.(indexOps)retrieves a child, thenparent.(indexOps) = childsupports writing it back.This issue should determine how reverse write-back should be planned when those assumptions are insufficient.
Option 1: Reuse the forward plan
Use the same chunks in both directions:
This is the current implementation. It has one plan and keeps resolved paths easy to understand, but it depends on both assumptions above.
Having the forward and write-back consistent means
resolvewill cleanly return only one option.Option 2: Choose shared boundaries for both directions
Plan forward traversal and reverse write-back together, requiring both directions to use the same boundaries:
The shared plan may use more boundaries than query traversal alone would require, but the forward and write-path plans will be identical and valid.
Having the forward and write-back consistent means
resolvewill cleanly return only one option.Option 3: Split forward chunks during write-back
Build the forward plan first, then divide its chunks further when assignment requires it:
The write-back planner may split
/A/Bif it cannot use the full/A/Bfor assignment. It cannot combine operations across boundaries chosen during forward traversal.This is more flexible than options 1 and 2, but the extra write-back boundaries are not visible in the original resolved path without changing the behavior of
resolve.Option 4: Plan both directions with independent boundaries
Plan both directions together, but allow each direction to have different chunks boundaries:
This allows the write-back planner to combine
/B/Ceven though the forward plan places a boundary between them.This is the most flexible option, but the different boundaries between forward and write-back would not be represented by
resolvewithout needing to change its behavior.It's unclear whether it is reasonable to require forward and write-back plans to be shaped identically or not. Choosing an option could require changing the resolved-input equivalence contracts.
There may also be ramifications with the stability under bare resolve and string round trip contracts. A mutation-aware resolved pointer should not lose or change its boundaries when resolved again, and if reverse-plan information ever becomes part of pointer syntax, rendering and reparsing must preserve it. Choosing an option where the forward and write-back plans are different could necessitate modifying
resolveso the user can effectively see the corresponding plan.The selected option should inform how the shared write-back from #47 is done.
remove#49remove#49