lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function for /score block


From: David Kastrup
Subject: Re: Function for /score block
Date: Thu, 25 Apr 2019 18:50:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Aaron Hill <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]