Pierre-Luc Gauthier <[email protected]> writes:
> Hello,
>
> tl;dr: why no multiple layout inheritance?
There is no "inheritance" at all.
> I'm trying to build a layout inheritance system. I'd like, for example,
> layoutC to inherit from both layoutA and layoutB:
>
> \version "2.27.3"
>
> layoutA = \layout {
> \override NoteHead.color = "red"
> }
>
> layoutB = \layout {
> \override Stem.thickness = 10
> }
>
> layoutC = \layout {
> \layoutA
> \layoutB % ERROR: bad expression type
> \override Stem.length = 20
> }
>
> \score {
> { c'4 d' e' f' }
> \layout { \layoutC }
> }
>
> Only one layout can be included, and it must be first.
It is not included. It is used as the starting point.
> I glanced at parser.yy (I'm no programmer). From what I understand,
> when parsing a \layout { } block, LilyPond sets a flag at the
> start. Including another layout (like \layoutA) is only allowed while
> this flag is set. After the first item is processed, the flag is
> cleared - so a second layout triggers "bad expression type".
That's more or less what happens.
> Questions:
> What is the rationale for allowing only one parent layout?
Layouts don't just contain what you see in them. They contain lots of
stuff that is either copied from a layout you explicitly state, or from
$defaultlayout.
Inheritance only makes sense with _sparse_ entities, but layouts are
full things.
> Could multiple includes be supported with "last setting wins"
> semantics?
I have no idea what you think that would accomplish. The last layout
would overwrite everything from the previous layouts anyway.
--
David Kastrup