lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

\fine, pre-process-in-final-translation-timestep & co.


From: Jean Abou Samra
Subject: \fine, pre-process-in-final-translation-timestep & co.
Date: Mon, 4 Jul 2022 23:12:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Moving some of the discussion from
https://gitlab.com/lilypond/lilypond/-/merge_requests/1451
to the mailing list.

In case that helps, this is a diagram of a revised translation
cycle that I was musing about for some (very) distant future:



Before                                    After
======                                    =====

initialize                        =>      initialize

[Time step cycle:]                        [Time step cycle:]

| start-translation-timestep      =>      | start-translation-timestep
|                                         |
| listeners                       =>      | pre-listeners <- RENAMING
|                                         |
| pre-process-music               =>      | pre-process-music
|                                         |
|                                         | post-listeners  <- NEW STEP
|                                         |
| process-music                   =>      | post-process-music <- RENAMING
|                                         |
| [Acknowledge cycle:]                    | [Acknowledge cycle:]
|                                         |
| | acknowledgers                 =>      | | pre-acknowledgers <- RENAMING
| |                                       | |
| |                                       | | pre-process-acknowledged <- NEW STEP
| |                                       | |
| |                                       | | post-acknowledgers <- NEW STEP
| |                                       | |
| | process-acknowledged          =>      | | post-process-acknowledged <- RENAMING
|                                         |
| stop-translation-timestep       =>      | stop-translation-timestep

finalize                          =>      finalize



My idea was that the frequent pattern

(let ((ev #f))
  (make-engraver
    (listeners
      ((some-event-class engraver event)
       (set! ev event)))
    ((process-music engraver)
     (when event
       ...))
    ((stop-translation-timestep engraver)
     (set! ev #f))))

could be abbreviated to

(make-engraver
  (post-listeners
   ((some-event-class engraver event)
    ...)))


Same for acknowledgers, lots of accumulating in vectors and clearing
those vectors can be eliminated.

Something like
https://gitlab.com/lilypond/lilypond/-/merge_requests/796
would have just been a matter of switching between #:once
and not #:once. (If I remember correctly. GitLab no longer
displays the diff, I'm not sure why.)

That would simplify quite a lot of engravers I think. Bonus:
process-music and stop-translation-timestep no longer have to
be called just for this trivial bookkeeping. It is originally
the speedup from commit 974009fcb894be5bee26563f740089f3c5eb0e67
that got me reflecting about that.

My understanding so far is that you need to exclude some events
in engravers because \fine, like overrides, can come at
any time during the "listeners" phase. If an engraver has
already recorded the event in its listener, it needs to
"unrecord" it somehow.

That could become very natural in the model above: if you
saw \fine (doing that in a pre-listener), just don't run
any post-listeners. Jump straight to post-process-music.
post-listeners and post-process-music are assumed to contain
everything that creates grobs from events. When
post-process-music creates grobs from events, those events
are assumed to have been recorded in post-listeners.

By now you know that I don't exactly have a speciality
of proposing the most straightforward solution solving
the problem at hand ...

Jean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]