[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Is ly:music? magic?
From: |
Jérôme Plût |
Subject: |
Is ly:music? magic? |
Date: |
Mon, 4 Feb 2013 09:41:45 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Given the following file:
-------
#(begin
(define ((K x) y) x)
(define testA (define-music-function (top location x) (ly:music?)
(make-music 'SequentialMusic 'void #t)))
; now we try to be clever
(define testB (define-music-function (top location x) ((K #t))
(make-music 'SequentialMusic 'void #t)))
)
\testA a % ok
\testB #'foo % ok
\testB a % fail
------
The file fails to compile only on the third line, \testB a . So
obviously, using ly:music? as a type predicate accepts more inputs than
the always-true predicate. The only explanation would be that the
parser knows that it is expecting a music expression; in other words,
(ly:music?) is not only a predicate.
By the way, (define test1 ly:music?) works as ly:music? in the example
above, whereas (define (test2 x) (ly:music? x)) does not.
So: is there a way to define a polymorphic music function (as testB
should be in the above example)?
--
Jérôme Plût
- Is ly:music? magic?,
Jérôme Plût <=