[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Optional arguments of a music-function?
From: |
Thomas Morley |
Subject: |
Optional arguments of a music-function? |
Date: |
Tue, 17 Jul 2012 13:13:59 +0200 |
Hi,
I tried to adapt the syntax-trickery David showed with the new
\tweak-definition to an own function.
Trying a code like the tiny example below fails.
proc =
#(define-music-function (parser location name arg)((string?) ly:music?)
(if name
#{ \once \override $name #'color = #red $arg #}
#{ \parenthesize $arg #}))
\relative c' {
c1
\proc "NoteHead" c
\proc c
}
Obviously I did sth wrong.
Well, I could do:
#(define-public (string-or-music? x)
(or (string? x) (ly:music? x)))
procII =
#(define-music-function (parser location arg)(string-or-music?)
(if (string? arg)
#{ \once \override $arg #'color = #red #}
#{ \parenthesize $arg #}))
\relative c' {
c1
\procII "NoteHead" c
\procII c
}
But I'd prefer the first version.
How to do?
-Harm
- Optional arguments of a music-function?,
Thomas Morley <=