[Top][All Lists]

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

Re: Scoped variables

From: Peter Toye
Subject: Re: Scoped variables
Date: Mon, 4 Nov 2019 09:28:23 +0000

On further consideration I think that Timothy Lanfear has, probably inadvertently, made my point for me.

If a publisher wanted to collect Mr. Lanfear's string quartets (assuming that he has written more than one) into a single volume, the Lilypond code would have to be changed to rename all of the variables to something like QiIViolinI (using Roman numerals to keep to the published convention of alphabetic characters only - I'm surprised that Mr. Lanfear's version works at all). Using my idea, and assuming that the variables were defined within the score, noting has to change apart from the book and possibly bookpart sections. Much easier and less error-prone. Also, if each staff's content is in its own file in the same directory as its score, the same code will serve for all movements:
  \score {
  \include ""
  \include ""
  \include ""
  \include ""

Now you can have a directory/file structure like:


I would offer to help with the programming, but I gave up professional programming many years ago. My last contact with Lisp was at university in the late 1960s.  I realise that this would not be a trivial job.

Best regards,


Sunday, November 3, 2019, 2:24:10 PM, David Kastrup wrote:

> Peter Toye <
address@hidden> writes:

>> 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.

> So what happens with

> bla = c'
> sc = \score { \bla }

> \book {
>   bla = f'
>   \sc
> }

> There are similar considerations for defining and using bookparts
> outside of books: basically the question is
> what scopes you even want to
> be talking about, lexical or dynamical, and how the two would be
> supposed to interact.

reply via email to

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