Re: Optional arguments for scheme functions

2020-04-26 Thread David Kastrup
Aaron Hill writes: > On 2020-04-26 10:01 am, David Kastrup wrote: >> Predicates used in argument parsing have to be "primary" in that they >> have to deliver a result for anything thrown at them. >> positive? only delivers results for numbers but throws an error for >> anything else. > > Would th

Re: Optional arguments for scheme functions

2020-04-26 Thread Aaron Hill
On 2020-04-26 10:01 am, David Kastrup wrote: Predicates used in argument parsing have to be "primary" in that they have to deliver a result for anything thrown at them. positive? only delivers results for numbers but throws an error for anything else. Would there be harm in redefining an R5RS

Re: Optional arguments for scheme functions

2020-04-26 Thread Fr. Samuel Springuel
> On 26 Apr, 2020, at 1:01 PM, David Kastrup wrote: > > Predicates used in argument parsing have to be "primary" in that they > have to deliver a result for anything thrown at them. > Can that be noted in the docs (http://lilypond.org/doc/v2.19/Documentation/extending/scheme-function-definitio

Re: Optional arguments for scheme functions

2020-04-26 Thread David Kastrup
"Fr. Samuel Springuel" writes: >> On 26 Apr, 2020, at 4:30 AM, Thomas Morley wrote: >> >> I've no clue why positive? fails here. >> Though, for integers >= 0 we have the index? predicate, which works in >> your function. > > Well, I’m glad I’m not the only one baffled. And the index? predicate

Re: Optional arguments for scheme functions

2020-04-26 Thread Fr. Samuel Springuel
> On 26 Apr, 2020, at 4:30 AM, Thomas Morley wrote: > > I've no clue why positive? fails here. > Though, for integers >= 0 we have the index? predicate, which works in > your function. Well, I’m glad I’m not the only one baffled. And the index? predicate does seem to work. > On 26 Apr, 2020

Re: Optional arguments for scheme functions

2020-04-26 Thread Lukas-Fabian Moser
Am 26.04.20 um 10:30 schrieb Thomas Morley: 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 han

Re: Optional arguments for scheme functions

2020-04-26 Thread Thomas Morley
Am So., 26. Apr. 2020 um 02:35 Uhr schrieb Fr. Samuel Springuel : > > 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 n

Optional arguments for scheme functions

2020-04-25 Thread Fr. Samuel Springuel
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