Simon Albrecht <simon.albre...@mail.de> writes: > Am 25.04.2015 um 13:17 schrieb David Kastrup: >> Simon Albrecht <simon.albre...@mail.de> writes: >> >>> Hello, >>> >>> as Harm has pointed out, the following example gives unexpected >>> (i.e. different) output: >>> >>> \version "2.19" >>> repeat-note = >>> #(define-music-function (parser location music)(ly:music?) >>> (make-sequential-music (list music (ly:music-deep-copy music)))) >>> >>> \absolute { c'1 \repeat-note c'' } >>> \relative c' { c \repeat-note c'1 } >>> >>> There are several possible ways of handling this: >>> – Document it as a feature of ly:music-deep-copy in its search >>> string. Users would have to circumvent it then. >> Huh? What makes you think this a "feature" of ly:music-deep-copy ? >> >> \absolute { c'1 { c'' c'' } } >> \relative c' { c { c'1 c'1 } } >> >> does exactly the same. > Now I see: I mistook ly:music-deep-copy to copy the music resulting > from the input, but it copies the input (before any music functions > such as \relative be applied). Is that correct?
Not really. ly:music-deep-copy copies its argument at the time it is called. It's a pretty ordinary Scheme function not in any way related to the parser. What _is_ related to the parser is the music function \repeat-note. It gets a music argument, calls among other things ly:music-deep-copy on it, and returns a sequential music expression. Which eventually is handed to \relative, _another_ music function. > In other words: my intuition served me badly here, where I didn’t > really know what the code was doing. I wrongly expected this > \repeat-note function to do the same as \repeat unfold 2 {}. I am afraid that \repeat unfold is _way_ more complicated. And one of the reasons is that it needs to work inside of \relative (if you search the old LilyPond history, you might hit issues when it did not yet do so). So instead of actually duplicating a music expression, repeat unfold adds a wrapper around that music expression and when it finally is processed, an "iterator" caters for the repetition, long long after any music expressions (like \relative and others) have worked on it. -- David Kastrup _______________________________________________ bug-lilypond mailing list bug-lilypond@gnu.org https://lists.gnu.org/mailman/listinfo/bug-lilypond