Hi Silvain!
The problem in your example is actually not the hierarchical combination
(nested alists), that works fine, the problem is naming the keys ”a” and ”b”.
If you rename them for instance music.3.aa and music.3.bb the example works.
I’m not sure why, but someone else can certainly explain.
I think the reason this isn’t in the documentation is that it can work in
somewhat unexpected ways if you don’t know what’s the scheme behind things is,
and if you’d explain that it would get quite long.
Consider for instance explaining why this doesn’t work without explaining
what’s behind the notation:
%%%%%%%%%%%%%%
\version "2.25.28"
phrase.1 = {c' d' e' d'}
phrase.1.aa = {c' d' e' a}
phrase.1.bb = {c' d' e' b}
{
\phrase.1
\phrase.1.aa
\phrase.1.bb
}
%%%%%%%%%%%%%%%
Best
/Leo
> 16 okt. 2025 kl. 14:20 skrev Silvain Dupertuis <[email protected]>:
>
> I would suggest to add this indication at this page of the documentation :
> https://lilypond.org/doc/v2.24/Documentation/learning/organizing-pieces-with-variables.fr.html
> https://lilypond.org/doc/v2.24/Documentation/learning/organizing-pieces-with-variables.html
> As for me, it took me a long time until I discovered this way to use numbered
> variables
> (I do not remember where, probably in some scheme explanation).
> It does not seem possible to combine hierarchically this kind of syntax.
> Here is a possible explanation included in a snippet.
> \version "2.24.4"
>
> \markup {
> Numbered variables
> }
>
> % ---------------------------------
> % these notation works
> music.1 = \relative c' {c2 d e1}
> music.2 = \relative c' {e2 d c1}
> music.end = \relative c' {c2 d c1}
>
> % ---------------------------------
> % this notation does not work
> % music.3.a = \relative c' {c2 d e1}
> % music.3.b = \relative c' {c2. d4 c1}
> % ---------------------------------
>
> \score {
> <<
> \music.1
> \music.2
> >>
> }
>
>
> \score {
> {
> \music.1
> \music.2
> \music.end
> }
> }
>
>
>
> \markup {
> \column
> \string-lines
> "
> .
> ======
> French
> ======
> On peut aussi utiliser une numérotation dans les noms de variables
> en utilisant un point avec la syntaxe NOMVARIABLE.NUM
> par exemple :
> music.1 = \relative c' {c2 d e1}
> music.2 = \relative c' {e2 d c1}
> music.end = \relative c' {c2 d c1}
> { \music.1 \music.2 \music.end }
> .
> =======
> English
> =======
> One can actually use numbered variable names
> using a dot and a syntax of the form VARIABLE.NUM
> for exemple:
> music.1 = \relative c' {c2 d e1}
> music.2 = \relative c' {e2 d c1}
> music.end = \relative c' {c2 d c1}
> { \music.1 \music.2 \music.end }
> .
> "
> }
>
>
> Le 14.10.25 à 06:01, Werner LEMBERG a écrit :
>>
>>> I have been using this trick to avoid these awkward English
>>> numerals... (/verse.1/ instead of /verseOne/, /verse.2/, etc.) but
>>> never tried this more sophisticated use.
>>>
>>> verse.1 = {...} — used as \verse.1
>>>
>>> It does create a single variable which refers to a structured Lisp
>>> object (an object with multiple slots), instead of distinct
>>> variables, but for the user, this does not change anything in the
>>> syntax itself.
>>>
>>> Unfortunately, this feature is very hard to find in the
>>> documentation. It would be nice to give this information in the
>>> main page explaining the syntax of variable names.
>>>
>> Where in the NR would you expect such documentation? Could you maybe
>> write something that I can add?
>>
>>
>> Werner
>>
> --
> Silvain Dupertuis
> Route de Lausanne 335
> 1293 Bellevue (Switzerland)
> tél. +41-(0)22-774.20.67
> portable +41-(0)79-604.87.52
> web: silvain-dupertuis.net