lilypond-user
[Top][All Lists]
Advanced

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

Re: Pull in external LilyPond files into a score of movements


From: David Kastrup
Subject: Re: Pull in external LilyPond files into a score of movements
Date: Mon, 28 Apr 2014 20:47:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Paul Morris <address@hidden> 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



reply via email to

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