Hello Harm and David,
Thanks for the explanations and example!
I copied a sample from the snippets and modified it, without taking care about detailed semantics. Now I know how to do things the right way depending on the context.
JM
Thomas Morley <address@hidden> writes:2017-06-25 8:40 GMT+02:00 Menu Jacques <address@hidden>:
Thanks Simon for the idea.
I’ve defined the following Scheme function for my needs, with accidental style forced to ‘forget' for the given note:
editorialAccidental = #(define-music-function (note) (ly:music?) #{ \once\accidentalStyle forget \once\set suggestAccidentals = ##t #note #})
{ \editorialAccidental cis4 cis4 dis4 \editorialAccidental cis4 }
JM
Hi Jaques,
while calling a variable, here 'note', in embedded lily-code, i.e. in #{ ... #}, always use $note not #note. Doing something with #note destructively changes 'note', so you can't access the unchanged 'note' anymore. Working on $note works on a copy of 'note' so you still have access to the original 'note'.
In this particular use case of using the material (of kind ly:music?)exactly once, #note is actually correct. This possibility of usingmaterial uncopied and destructively is useful for processing largeamounts of music like with\relative c' { 100 lines of stuff }In cases like that, not creating a copy for music that is justtransitionally used is fine. In many other cases, you are right that itisn't, and the error symptoms are hard to understand and occur onlyunder some circumstances (uses of \relative and \transpose are ofteninvolved but by no means the only triggers).-- David Kastrup
|