[Top][All Lists]

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

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

From: Paul Morris
Subject: Re: Issue 3918: Add \alternatingTimeSignatures (issue 97110045)
Date: Thu, 5 Jun 2014 06:12:47 -0700 (PDT)

Thomas Morley-2 wrote
> Hi Paul,
> in general I disagree.
> Nearly every time I thought I'd need a predicate for multiple
> argument-types, I found a way to code it better/simpler.

Hi Harm,
Maybe you're right that better/simpler code uses single-type arguments.  I'm
not convinced but I'll defer to those with more experience.  

In any case, 10 of the 26 LilyPond scheme predicates[1] are "x-or-y?"
combinations, which suggests that they are useful.  Defining each
combination one by one like this seems like a kind of hard coding to me.
Wouldn't it be better to have a general way to combine types as needed for
any given case?  As you say below there are already some workarounds
available to users.


Thomas Morley-2 wrote
> OTOH, we have already the most general `scheme?'-predicate. You can
> use it first and sort the argument-types later.
> 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.)  

What if a list of type predicates was a valid type predicate?

  '(boolean? number? procedure?)

Their individual descriptions could be combined for error messages.  

At the end of the day this is a small and incremental thing and I don't want
to belabor it.


View this message in context:
Sent from the Dev mailing list archive at

reply via email to

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