Paul Morris <[email protected]> writes:
> Hi David,
>
>
> David Kastrup wrote
>>> Your "doScore" function seems to be a workaround for the limitation
>>> that music functions can't return a score.
>>
>> That's not a "limitation". A music function returning a score makes as
>> little sense as an integer function returning a complex number.
>>
>> If you want to return a score, don't use a music function.
>
> Ok, point taken. I guess I had not fully internalized the distinction in
> the code between music and a score. At any rate, I did not intend any
> criticism of the design or implementation of music functions. Just glad to
> have an example of a way to write a scheme function that returns a score.
> That's something I had not been able to figure out on my own before.
Ugh.
doScore =
#(define-void-function (parser location cond? mus)(procedure? ly:music?)
; if condition is met, parser shall create score
(if (cond? parser location)
(begin
(ly:parser-define! parser 'doScoreMusic mus)
(ly:parser-include-string parser (format "\\score { \\doScoreMusic }"))
)))
With current LilyPond (as of 2.19.0, issue 3728), you could likely do
better with something like
doScore =
#(define-scheme-function (parser location cond? mus) (procedure? ly:music?)
(if (cond? parser location)
#{ \score { #mus } #}))
--
David Kastrup
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user