ly:make-music-function issue (bug?)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ly:make-music-function issue (bug?)

Daniel Schmolze
I've written a function that accepts three arguments and returns a function that
accepts some music. The function looks like this (for the purposes of this post):

#(define (foo a b c) (lambda (m) m))

Now, this works fine:

{ \applyMusic #(foo 1 2 3) {a' b' c''} }

However, I'd like to be able to do the following:

{ \foo #1 #2 #3 {a' b' c''} }

So I tried this:

blah = #(ly:make-music-function
        (list number? number? number? ly:music?)
        (lambda (parser location a b c music)
          ((foo a b c) music)))

{ \blah #1 #2 #3 {a' b' c''} }

Which gives me "error: can't find signature for music function".

Now here's the odd part. If I change the function to accept less than three
arguments, everything works as expected:

#(define (foo a b) (lambda (m) m))

blah = #(ly:make-music-function
        (list number? number? ly:music?)
        (lambda (parser location a b music)
          ((foo a b) music)))

{ \blah #1 #2 {a' b' c''} }

What gives?



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: ly:make-music-function issue (bug?)

Erik Sandberg
On Sunday 26 March 2006 18.54, Daniel Schmolze wrote:

> I've written a function that accepts three arguments and returns a function
> that accepts some music. The function looks like this (for the purposes of
> this post):
>
> #(define (foo a b c) (lambda (m) m))
>
> Now, this works fine:
>
> { \applyMusic #(foo 1 2 3) {a' b' c''} }
>
> However, I'd like to be able to do the following:
>
> { \foo #1 #2 #3 {a' b' c''} }
>
> So I tried this:
>
> blah = #(ly:make-music-function
> (list number? number? number? ly:music?)
> (lambda (parser location a b c music)
>  ((foo a b c) music)))
>
> { \blah #1 #2 #3 {a' b' c''} }
>
> Which gives me "error: can't find signature for music function".
>
> Now here's the odd part. If I change the function to accept less than three
> arguments, everything works as expected:

It has to do with the way function calls are handled by the parser. Currently,
there is a short list of hard-coded signatures which are allowed; grep
parser.yy for FUNCTION to see which ones. It's a rather dirty solution, which
is waiting for a cleanup.

--
Erik


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel