[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: predicate pitch-or-music? - getting rid of ##{ #} ?
From: |
David Kastrup |
Subject: |
Re: predicate pitch-or-music? - getting rid of ##{ #} ? |
Date: |
Fri, 19 Oct 2012 21:59:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
Thomas Morley <address@hidden> 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
- predicate pitch-or-music? - getting rid of ##{ #} ?, Thomas Morley, 2012/10/19
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?,
David Kastrup <=
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Thomas Morley, 2012/10/19
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/21
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, David Kastrup, 2012/10/23
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, David Kastrup, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Thomas Morley, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Werner LEMBERG, 2012/10/24