lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme optional arguments, number-list


From: David Kastrup
Subject: Re: Scheme optional arguments, number-list
Date: Sat, 23 Apr 2016 15:01:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Mark Knoop <address@hidden> writes:

> On upgrading to 2.19.32, one of my regular functions no longer works.
> It seems that a single number as the first argument is now accepted as a
> number-list whereas before it was not and thus became the second
> argument.
>
> Whilst the new possibility to write lists as 1,2,3,4 is very nice, is
> there any way to alter my function definition to achieve the old
> behaviour?
>
> myFunction = #(define-void-function
>   (a b c d)
>   ((number-list? '()) number? (boolean? #t) fraction?)
>   (print "\na=~s b=~s c=~s d=~s\n" a b c d))
>
> {
>   % this works when all arguments are specified
>   \myFunction 1,2,3,4 4 ##t 4/4
>   % not specifying first argument no longer works
>   \myFunction 4 4/4
> }

You can write your own predicate that will reject lists containing a
single number.  But it will then also reject an explicit #'(3).  I'm
afraid that you just created an interface that was too delicate to
survive further development.

Of course, you can always skip an optional argument using \default, but
that's likely not what you would want to do.

-- 
David Kastrup



reply via email to

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