lilypond-user
[Top][All Lists]
Advanced

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

Optional arguments for scheme functions


From: Fr. Samuel Springuel
Subject: Optional arguments for scheme functions
Date: Sat, 25 Apr 2020 20:34:37 -0400

I’m trying to write a music function in scheme in which the first argument is 
optional and have run into something that confuses me:

The following works:

\version "2.19.84"

recite = #(define-music-function (times note) ((integer? 1) ly:music?)
                   #{ \repeat unfold #times { #note }
                   #})

\new Staff {
    \new Voice { g' \recite g' g' }
}

However, when I swap integer? for positive? (to reflect the fact that only a 
positive integer should be acceptable) it breaks, telling me the argument at 
position 1 is of the wrong type (it’s music, not a positive number).  Why 
doesn’t scheme’s handling of optional arguments work when using the positive? 
predicate?

✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝
Fr. Samuel, OSB
(R. Padraic Springuel)
St. Anselm’s Abbey
4501 South Dakota Ave, NE
Washington, DC, 20017
202-269-2300
(c) 202-853-7036

PAX ☧ ΧΡΙΣΤΟΣ




reply via email to

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