|
From: | Flaming Hakama by Elaine |
Subject: | Re: bookparts |
Date: | Mon, 5 Mar 2018 16:30:17 -0800 |
From: David Kastrup <address@hidden>
To: Wols Lists <address@hidden>
Subject: Re: bookparts
Wols Lists <address@hidden> writes:
> On 05/03/18 17:55, Kieren MacMillan wrote:
>> Hi Knut,
>>
>>> Because the definition of testing is invalid at that point of the main
>>> source file. If tempTest.ly would contain e.g. a score or a \paper block
>>> no error would occur.
>>
>> No, it still throws an error because you can't define a variable
>> inside a \bookpart (which is what \include-ing it at that point
>> does).
>>
> And as a programmer, I think "scope". You are defining the variable
> where you want to use it.
That's not what "scope" means.
> It's widely accepted that that is good practice, global variables lead
> to errors, mistakes and confusion. But here you are forced to declare
> your variables at the global level :-(
Bookparts at global level are collected into an implicit book. If books
have a scope of their own, no "global" definitions would be visible in
explicit books since they would be separate from the scope in the
implicit book.
Unfortunately, there does not appear to be a concept readily consistent
with scoping the current book/bookpart design. Because "scope" does not
mean "you are defining the variable where you want to use it". A
consequence of well-defined scopes is that you can more often do it in
that manner without impacting other code. But I haven't seen a good
"well-definition" with LilyPond. I am pretty sure that people would
protest books not getting to see definitions made "outside" of them. So
normal books would have to be nested in the implicit default book like
bookparts of the implicit book are.
[Prev in Thread] | Current Thread | [Next in Thread] |