2012/10/19 David Kastrup <d...@gnu.org>: > Thomas Morley <thomasmorle...@googlemail.com> writes: > >> Hi, >> >> I tried to create a function which should accept a pitch _or_ music. >> So I defined a pitch-or-music? predicate: >> >> #(define (pitch-or-music? x) >> (or (ly:pitch? x) (ly:music? x))) >> >> Calling the function, I have to use ##{ ... #} for music _and_ for a >> single pitch. > > For music it should work anyhow. The problem with pitch is that at the > current point of time, ly:pitch? and ly:duration? are specially detected > and specially treated, so even if you do > > #(define (mypitch? x) (ly:pitch? x)) > > it will not work. However, the predicate does not make all that much > sense since every pitch is also valid music. If we fastforward a few > months until pitch? is no longer special-cased, the parser will see the > pitch, try passing it as a pitch to the predicate and, since the > predicate accepts, will _stick_ with this choice. You could pass music > by starting with { or so. > >> Calling the function for a single pitch doesn't work, if ##{ #} are >> omitted, but it'll work if the predicate would be ly:pitch? >> I don't understand this behaviour. > > Welcome to the club. In 2.14, _all_ predicates were special-cased, and > people did not understand it. Pitches and durations are hardest to > normalize. I am on it, but then frequent other projects got in between. > >> Is there any possibility to get rid of ##{ #}, when calling the >> function with a single pitch, but to keep the possibility to call it >> with some music? > > Well, I have the xxx.xxx.xxx project pending (and it will be quite a bit > of work to document as well), waiting for the 2.16.1 release (also my > responsibility) in order to get the translation branches switched over > from 2.16 to 2.17. Then I can get back to the pitch and duration > problem. Several weeks. > > -- > David Kastrup
Hi David, thanks for your reply, I'll wait. :) Let me take the opportunity to express my deepest gratefulness for all your work, not only for developing LilyPond, but for all the time you spend on the user-list, answering/solving all kind of questions/problems. Best, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user