\book/\bookpart local scopes, assignments, variables (was: Plea for money, development proposal)

David Kastrup <[email protected]> Mon, 03 Aug 2026 02:06:04 +0200
Newsgroups gmane.comp.gnu.lilypond.devel,gmane.comp.gnu.lilypond.general
Organization Organization?!?
Message-ID <[email protected]>
David Kastrup <[email protected]> writes:

> So as to the work: I think I can likely put in work to allow assignments
> in \book/\bookpart blocks.  This would facilitate modularizing LilyPond
> source.  The syntax changes are easy (but for whatever reason, few
> people like touching the parser); the problematic part is scoping.  When
> I last was active, Guile modules were an ill-documented opaque affair.
> Now that we have migrated to Guile 2+, they are, well, an ill-documented
> opaque affair but more consistent and predictably so.
>
> There is a good chance that if I do the original work, any problems
> creeping up afterwards are within the purview of what other developers
> feel somewhat safe experimenting with.  So even if I do happen to get a
> job not leaving me more time for LilyPond, this should not end up being
> unmaintanable bit rot.  That would be more or less the deal for next
> month.
>
> So that's what you need to know in a nutshell: I am out of money and see
> some opportunity for doing LilyPond work.  \book/bookpart scoping should
> be good for a month of work at my somewhat ineffective balance of
> thinking things through too much before coding.  Contact me if you want
> to be part of the monetary solution of those problems.  Or the coding.

Ok, this is embarrassing, to say the least.  Documentation is still
missing.  But other than that it would appear like this was ridiculously
easy so far.  One snippet broke because it made assumptions about the
scopes in books.

As a corrollary, the most likely impacted existing projects will be
those using home-grown code messing with hooks and other stuff in
connection with books and/or modules.

If you compile LilyPond from scratch, please test this merge request on
some work of yours containing \book or \bookpart blocks.

You may also test what happens when wrapping a \book less LilyPond file
into a book block: previously this tended to throw up on any
assignments.

<https://gitlab.com/lilypond/lilypond/-/merge_requests/3111>

-- 
David Kastrup