lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme function containing score {...}


From: David Kastrup
Subject: Re: scheme function containing score {...}
Date: Fri, 24 Nov 2017 18:18:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Gianmaria Lari <address@hidden> writes:

> I'm trying to put the score functionality inside a function (consider it a
> test). Here it is the code:
>
> \version "2.19.80"
> myScore =
> #(define (music) (ly:music?) #{
>   \score {
>     $music
>     \layout{}
>     \midi{}
>    } #} )
>
> \myScore {a b c'}
>
>
> The code correctly generate a score but it does not generate the midi file.
> Why???

There is a difference between define (which defines a pure Scheme
function or expression) and define-music-function (which defines
something taking arguments in LilyPond syntax and returning a music
expression) and your input is an interesting mashup where \myScore will
probably be left as *unspecified* after you define an argumentless
Scheme function named `music' that first calls ly:music? without
argument and then would return a score if the ly:music? call had not
already caused an error due to a missing argument.

Now a score is not a music expression anyway, so you should rather
replace define with define-scheme-function here in order to avoid
errors: the resulting \myScore can then return arbitrary expressions
including whole scores.

-- 
David Kastrup



reply via email to

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