> I have the following script:
>
> \version "2.26.0"
> \book {
> \bookpart{
> foo = { c'1 } <-- Fehler: syntax error, unexpected SYMBOL.
> \score {
> \new Staff \foo
> }
> }%%bookpart
> }%%book
>
> The definition of foo is not allowed within bookpart.
>
> Consequences: within bookpart, lilypond-definitions must be replaced
> by scheme-definitions.
>
> In the description of lilypond often is recommended to use
> lilypond-variables, to prepare songs. I expect, lilypond
> definitions of variables like "foo = { c'1}" should be accepted.
Have you looked up the documentation for `\bookpart`? Searching for
this command in the index brings you to
https://lilypond.org/doc/v2.26/Documentation/notation/multiple-scores-in-a-book
where you can find the following.
By design, you cannot define variables within a ‘\book’ or
‘\bookpart’ block (the same is true for ‘\score’, by the way);
[...]
There is no bug; it is a parser restriction by design. The
documentation also shows a solution how to circumvent it, and as
you've found out, Scheme code can also be used as an alternative.
Werner