Is there a case for introducing scoped variables into Lilypond? 

As I understand it (please correct me if I'm wrong), variables have to be 
declared at the top of the document, before any music expression. I'm trying to 
work on a document with many different scores, each if which is in its own 
file. According to what I gather is best practice I use variables to hold the 
basic music text: one variable for each staff. When engraving each individual 
score, I need to put its variable declarations at the head of its file. But 
when I want to gather them all together into a book or bookpart, this doesn't 
work, so each score has to be edited to remove the definitions.

One way round this would be to allow Lilypond variables to be defined within 
bookparts and/or scores, and to give them a scope confined to that section. See 
the following MNWE.

\version "2.19.52"
\language "english"
\book {
  \bookpart {
    music = { f''4 4 4 4 }
    \score {
      \new Staff
      {
        \time 4/4
        \music
      }
    }
  }
  \bookpart {
    music = { e''4 4 4 }
    \score {
      \new Staff
      {
        \time 3/4
        \music
      }
    }
  }
}

I realise that this would probably be a major change, and so I hesitate to 
suggest it formally unless there is a consensus of opinion in its favour. It 
would however make "bottom-up" document production a lot easier, as local 
information would be encapsulated. This, after all, has been best practice in 
language design for some time now.

What do the experts think?

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

Reply via email to