lilypond-user
[Top][All Lists]
Advanced

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

Re: \bookpart mystery


From: David Sumbler
Subject: Re: \bookpart mystery
Date: Tue, 05 Jun 2018 16:46:41 +0100

On Mon, 2018-06-04 at 13:43 -0700, Aaron Hill wrote:
> On 2018-06-04 08:54, David Sumbler wrote:
> > 
> > In my efforts (largely successful) to find a way easily to control
> > conditional compilation, I came across this apparent anomaly.
> > 
> > The following two short examples work as one might expect:
> > 
> > %%%%%
> > \book {
> >   \score { g }
> > }
> > %%%%%
> > 
> > %%%%%
> > var =
> > \book {
> >   \score { g }
> > }
> > 
> > \var
> > %%%%%
> > 
> > Adding a \bookpart to the first also works as expected:
> > 
> > %%%%%
> > \book {
> >   \bookpart {
> >     \score { g }
> >   }
> > }
> > %%%%%
> > 
> > But putting this into a variable thus:
> > 
> > %%%%%
> > var =
> > \book {
> >   \bookpart {
> >     \score { g }
> >   }
> > }
> > 
> > \var
> > %%%%%
> > 
> > causes parsing errors.
> > 
> > For my better understanding of how LilyPond works, can somebody
> > explain
> > to me why this happens?
> > 
> > David
> I tried a few more permutations and found you can do this:
> 
> %%%%
>    \version "2.19.81"
>    varOne = \bookpart { \score { g } }
>    varTwo = \book { \varOne }
>    \varTwo
> %%%%
> 
> But going back to your original code, given the output from
> lilypond...
> 
> > 
> > GNU LilyPond 2.19.81
> > Processing `bookpartvar.ly'
> > Parsing.../usr/local/lilypond/usr/share/lilypond/current/scm/lily-
> > library.scm:243:5:
> >  In procedure ly:book-process in expression (process-procedure
> > book 
> > paper ...):
> > /usr/local/lilypond/usr/share/lilypond/current/scm/lily-
> > library.scm:243:5:
> >  Wrong type (expecting real number): #<undefined>
> ...here are the lines leading up to and including 243 from 
> lily-library.scm:
> 
> %%%%
>    (define (print-book-with book process-procedure)
>      (let* ((paper (ly:parser-lookup '$defaultpaper))
>             (layout (ly:parser-lookup '$defaultlayout))
>             (outfile-name (get-outfile-name book)))
>        (process-procedure book paper layout outfile-name)))
> %%%%
> 
> It would seem there is a problem with the so-called "default
> paper".  
> That led me to try this:
> 
> %%%%
>    \version "2.19.81"
>    var = \book { \bookpart { \paper {} \score { g } } }
>    \var
> %%%%
> 
> And that compiles.
> 
> -- Aaron Hill

That's very interesting - you have clearly found where the problem
arises, and I'm rather cross with myself for not having taken the
trouble to find it myself.

It's still a mystery to me, though, why this only causes a problem when
the \book is in a variable.

Without a \bookpart it all works fine.  The following also works
without errors:

%%%%%
\version "2.19.81"
var = \bookpart { \score { g } } 

\book { \var } }
%%%%%

It seems, then, that the error only arises if there is a \bookpart
 within a \book which itself is stored in a variable.

Strange!

David





reply via email to

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