Aaron Hill <lilyp...@hillvisions.com> writes:

> But even with that constraint, I found the following works and avoids
> the string concatenation:
>
> %%%%
> \version "2.19.82"
>
> Alice.Lyrics.StanzaI = \lyricmode { a b c }
> Alice.Lyrics.StanzaII = \lyricmode { d e f }
>
> Bob.Lyrics.StanzaI = \lyricmode { g h i }
> Bob.Lyrics.StanzaII = \lyricmode { j k l }
>
> foo = #(define-music-function (singer stanza) (symbol? symbol?)
>   #{ \new Lyrics { $(ly:parser-lookup singer) . Lyrics . $stanza } #} )
>
> \foo Alice StanzaI
> \foo Bob StanzaII
> %%%%
>
> Curious though why in the above, I can say "Alice" in lieu of
> "#'Alice". Is it simply because the music function's type assertion of
> "symbol?" lets the parser consume the next string as such?

Yes.  The more restrictive the predicate, the more work the parser will
invest to try converting it to the required type.  For better or worse,
LilyPond syntax is context dependent.  Music functions are as versatile
and "natural" as they are by using their predicates as context advice.

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to