lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is ly:music? magic?


From: David Kastrup
Subject: Re: Is ly:music? magic?
Date: Mon, 04 Feb 2013 09:55:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Jérôme Plût <address@hidden> writes:

> 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
>
> ------

You should _always_ be specifying the version you use.  Starting with
version 2.15.16, ly:music? has ceased being magic as a predicate.
However, starting with version 2.15.13, the predicate list is specially
parsed to support optional function arguments, so predicates _need_ to
be a single symbol.

> By the way, (define test1 ly:music?) works as ly:music? in the example
> above, whereas (define (test2 x) (ly:music? x)) does not.

That sounds pre-2.15.16.  The current stable version is 2.16.2.  Please
consider upgrading.

> So: is there a way to define a polymorphic music function (as testB
> should be in the above example)?

I am not sure what you call "polymorphic", but at any rate, you should
upgrade your version of LilyPond before further experiments, or your
results will be rather shortlived.

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]