pabuhr <pab...@fastmail.fm> writes:

>    I consider it much nicer to make "strg" of type fraction?, and then num
>    can be (car strg) and denom can be (cdr strg).
>    and
>    can just be \spreadTimeSignature #8 2/4 ... which is nicer on the eyes.
>
> I was intrigued and tried to modify the code as you suggested as a
> learning exercise. But I ran into a problem I do not understand. I
> assumed that fraction is a pair of two numbers, so num and denom are
> of type number. "column" needs strings so the numbers have to be
> converted. However, I get the following error:

> test12.ly:18:25: error: syntax error, unexpected NUMBER_IDENTIFIER
>        (number->string 
>                          $num)
> /usr/local/lilypond/usr/share/lilypond/current/ly/init.ly:61:0: error: error 
> in #{ ... #}
>
> I think I'm close but missing some subtle issue about the types.
>
> ============================================================================================
>
> \version "2.16.0"
> \language english
> #(set-global-staff-size 30)
>
> spreadTimeSignature =
> #(define-music-function (parser location baselineSkip strg music)(number? 
> fraction? ly:music?)
>   (let* ((num (car strg))
>        (denom (cdr strg)))
>    #{
>    \override Staff.TimeSignature #'stencil =
>    #(lambda (grob)
>      (grob-interpret-markup grob
>       #{
>       \markup %\fontsize #5
>       \vcenter
>       \override #`(baseline-skip . ,baselineSkip)
>       \column {
>        (number->string $num)

This needs to be $(number->string num) instead, as the expression you
want to splice in here "as if it were written in LilyPond" includes the
Scheme call.

Other than that (same with denom), the code looks fine to me.

-- 
David Kastrup

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

Reply via email to