lilypond-user
[Top][All Lists]
Advanced

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

Re: Bug with transpose in functions


From: David Kastrup
Subject: Re: Bug with transpose in functions
Date: Fri, 12 Jul 2019 12:49:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Immanuel Litzroth <address@hidden> writes:

> This seems to do the wrong thing:
>
>>
> \version "2.19.81"
> testme = #(define-music-function
>            (parser location music)
>            (ly:music?)
>            #{
>              \transpose c c' {#music } {#music }
>              #})
> \testme g'
>>
> printing out two g'' instead of a g'' and a g'

Functions like transpose act destructively on their argument, so you
need a copy or the original will get changed.  Write $music to get a
copy, or use ly:music-deep-copy .

> Also I found it strange that {#music} is not accepted as an argument with
> the
> following error:
>>tmp.ly:6:16: error: GUILE signaled an error for the expression beginning
> here
>>            {#
>>              music}
>>Unbound variable: music}
> It seems to parse the closing } as part of the variable name.

Correct.  Scheme syntax is very simple.  Some characters like ()" act as
delimiters, but most others are only split into words with intervening
spaces.  LilyPond syntax is different, but writing # or $ hands control
over to the Scheme parser.

-- 
David Kastrup



reply via email to

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