lilypond-devel
[Top][All Lists]
Advanced

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

Re: Issue 3918: Add \alternatingTimeSignatures (issue 97110045)


From: Thomas Morley
Subject: Re: Issue 3918: Add \alternatingTimeSignatures (issue 97110045)
Date: Fri, 6 Jun 2014 01:39:40 +0200

2014-06-05 15:12 GMT+02:00 Paul Morris <address@hidden>:
> Thomas Morley-2 wrote
[...]
>> And really hackish is:
>>
>> test =
>> #(define-music-function (parser location test-arg mus)
>>    (
>>     ;very bad, kludgy and hacky, though valid:
>>     ((lambda (x) (or (boolean? x) (number? x) (procedure? x))) "")
>>     ;scheme?
>>     ly:music?
>>     )
>>
>>     (cond ((boolean? test-arg)
>>            (format #t "\n~a is a boolean." test-arg))
>>           ((number? test-arg)
>>            (format #t "\n~a is a number." test-arg))
>>           ((procedure? test-arg)
>>            (format #t "\n~a is a procedure." test-arg))
>>           (else #f))
>>     mus)
>>
>> m = { c''1 }
>>
>> \test ##f \m
>> \test #3 \m
>> \test #(lambda (a) a) \m
>
> Good point about "scheme?", although it is so general that it doesn't tell
> you which combination of types are expected, while this does:
>
>   ((lambda (x) (or (boolean? x) (number? x) (procedure? x))) "")
>
> I'm not sure I understand why this is so bad.  It seems better than
> "scheme?" here since it is more specific.  I had tried to do this before but
> I didn't know I needed to include the "" at the end.  (I assume this "" is
> the description and could be changed to "boolean, number, or procedure" so
> error messages would be accurate.)

No.
It abuses the syntax for an _optional_ argument, with the default ""

Look at:

testII =
#(define-music-function (parser location test-arg mus)
   (
    ;very bad, kludgy and hacky, though valid:
    ((lambda (x) (or (boolean? x) (number? x) (procedure? x))) "xy")
    ;scheme?
    ly:music?
    )
    (format #t "\nThe default for \"test-arg\" is ~a." test-arg)
    mus)

m = { c''1 }

\testII \m


Cheers,
  Harm



reply via email to

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