Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9468)

Issue 131770043: Issue 3072: Nested overrides get confused with multiple contexts in play (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 8 months ago by dak
Modified:
9 years, 6 months ago
Reviewers:
lemzwerg, Carl
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

Issue 3072: Nested overrides get confused with multiple contexts in play The main problem with nested overrides lies not as much with the override (which can be done reasonably well) but rather with the corresponding reverts. Detecting and undoing a previously established nested override by its effects on an alist, particularly when nested overrides may be present at several different levels in several different contexts and/or stack depths and may be undone in different order from being established, is a complex problem. It is complex enough that it is not clear that a satisfactory solution does even exist: at least LilyPond's implementation breaks down for a number of test cases. The approach of this implementation is to not even try reverting nested overrides from looking at their effects on the final result. Instead nested overrides like \override Staff.TextSpanner.bound-details.left.text = #"foo" are not done by creating an assembled alist element for TextSpanner looking like (bound-details . ((left . ((text . "foo") ...)) ...)) with ... filled in from other parts of the alist (which may change independently at a later point of time) but rather by using (bound-details left text) itself as a key and thus storing ((bound-details left text) . "foo") as the representation of the override. Consequently, reverting an override with the same nested property path is straightforward. Neither the action of overriding nor of reverting now require referring to or updating any part of the property stack outside of the current context. The downside is that an actual reference to the resulting grob alist requires expanding the nested overrides at the time of creating a grob or otherwise asking for ly:context-grob-properties. Since issue 2507 encapsulated grob property access into the Grob_property_info algorithm container structure relying on data stored in context properties of elements of type Grob_properties, changing the respective algorithms can be facilitated completely in those classes. In order to provide similarly efficient access and reasonable caching and just-in-time reevaluation of previously computed values, Grob_properties needed to be significantly extended in size.

Patch Set 1 #

Patch Set 2 : Actual changes on top of issue 2507 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+508 lines, -246 lines) Patch
M input/regression/scheme-text-spanner.ly View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/auto-beam-engraver.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/context-property.cc View 1 7 chunks +201 lines, -148 lines 0 comments Download
M lily/context-scheme.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/engraver.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/engraver-group.cc View 3 chunks +6 lines, -8 lines 0 comments Download
M lily/include/context.hh View 1 2 chunks +4 lines, -7 lines 0 comments Download
A lily/include/grob-properties.hh View 1 chunk +59 lines, -0 lines 0 comments Download
M lily/include/lily-proto.hh View 1 chunk +1 line, -0 lines 0 comments Download
M lily/nested-property.cc View 1 1 chunk +220 lines, -71 lines 0 comments Download
M lily/score-engraver.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/span-bar-stub-engraver.cc View 2 chunks +2 lines, -1 line 0 comments Download
M ly/event-listener.ly View 1 chunk +2 lines, -2 lines 0 comments Download
M ly/music-functions-init.ly View 1 chunk +2 lines, -2 lines 0 comments Download
M scm/define-grobs.scm View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 6
dak
Actual changes on top of issue 2507
9 years, 8 months ago (2014-08-16 15:48:03 UTC) #1
dak
Actual changes on top of issue 2507
9 years, 8 months ago (2014-08-16 16:22:16 UTC) #2
lemzwerg
I don't actually understand the code, but I like the encapsulation, so: LGTM.
9 years, 8 months ago (2014-08-16 18:36:50 UTC) #3
dak
On 2014/08/16 18:36:50, lemzwerg wrote: > I don't actually understand the code, but I like ...
9 years, 8 months ago (2014-08-16 18:55:57 UTC) #4
Carl
On 2014/08/16 18:55:57, dak wrote: > On 2014/08/16 18:36:50, lemzwerg wrote: > > If you ...
9 years, 8 months ago (2014-08-23 20:40:21 UTC) #5
dak
9 years, 8 months ago (2014-08-23 21:41:43 UTC) #6
On 2014/08/23 20:40:21, Carl wrote:
> On 2014/08/16 18:55:57, dak wrote:
> > On 2014/08/16 18:36:50, lemzwerg wrote:
> > 
> > If you like the encapsulation, you like the patch for issue 2507.  If you
like
> > that nested properties will just work without handwaving and ifs and buts,
you
> > like this issue.
> 
> I really like this solution.  I spent some time trying to figure out how to
get
> reverts
> right during my work on beaming; I never found a good algorithm.

Neither did I, and I spent a non-trivial amount of time over the last years
(there are some rather old "I will do this" kinds of comment on the respective
issues that were actually bolstered by sketches, code, planning, pseudocode
etc).  So this does not even try.  It just reapplies all remaining nested
overrides from scratch when a result is needed, with some caching/memoization to
avoid the effort for some trivial but frequent situations (like not using nested
overrides at all).  I am still not 100% sure that it would not have been doable
in the original spirit.  But I'm pretty sure that it would have been very hard
to convincingly prove correct.

I spent a lot less time on writing this version that I spent on trying to get
the problems from the original approach under control.  And I spent no time at
all now on drawing diagrams of data structures and brooding over their
implications depending on the order in which several modifications were applied.
 The remaining bugs after getting the stuff to compile were of the "stupid typo"
rather than "weird special case" type.  All that is a good sign.

> I love the encapsulation.  Separating implementation from function is always
good.

Well, the bookkeeping of the internal data structures was scattered all over the
place.  Keeping it in that manner would not have been prudent given the
additional complexity.  I probably spent more time on the encapsulation than
actually replacing the internals.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b