lilypond-user
[Top][All Lists]
Advanced

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

Re: Control of score visibility based on variables


From: Matthew Fong
Subject: Re: Control of score visibility based on variables
Date: Sat, 5 Dec 2020 07:31:38 -0800

Hello Lukas,

Many thanks for the clarification. My apologies for the belated reply since my week got quite busy. I understand your explanation: You can also use the question mark in the variable name, which confused me for a moment.

I think I was mixing information I read previously about predicates in LilyPond, and thought myself restricted to the list here:
http://lilypond.org/doc/v2.20/Documentation/notation/predefined-type-predicates

I could also modify your to use a boolean explicitly:
scoreIf = #(define-void-function (some-condition score) (boolean? ly:score?)
     (if some-condition (add-score score)))

But I'm really no Scheme expert. Still hacking my way through.


Many thanks,
mattfong

On Thu, Dec 3, 2020 at 8:45 AM Lukas-Fabian Moser <lfm@gmx.de> wrote:
Hi Matthew,

Am 03.12.20 um 01:50 schrieb Matthew Fong:
> ... and I will have use of question? Didn't know about that!

In fact, that's just an arbitrary name for a variable! (And, to be
honest, I wasn't completely happy with my choice.)

So, the following would work just the same:

scoreIf = #(define-void-function (some-condition score) (scheme? ly:score?)
     (if some-condition (add-score score)))

I would have liked to use "condition" or "cond", but these are reserved
words in Guile, if I'm not mistaken. Maybe "print-it" would be a nice
name: "if print-it (add-score score)" seems to be quite self-explanatory.

As for the ? in "question?": By convention, names ending in "?" are used
for "predicates", that is, functions returning only #t or #f as values.
I seem to remember that some people extend this convention and use the ?
also for variables that should contain boolean values (#t/#f), and
that's what I did here.

Lukas


reply via email to

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