lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme help request: How can else of an if-statement be made to do n


From: Matthew Fong
Subject: Re: Scheme help request: How can else of an if-statement be made to do nothing?
Date: Sat, 17 Oct 2020 10:27:32 -0700

Hello Richard,

I just discovered your explanation is in fact the case, and also concluded cond wouldn't work either.

I might have to settle for an empty markup block for now.


Many thanks,
mattfong

On Sat, Oct 17, 2020 at 9:55 AM Richard Shann <richard@rshann.plus.com> wrote:
On Sat, 2020-10-17 at 09:34 -0700, Matthew Fong wrote:
> Hello everyone,
>
> No less than 10 minutes after, I discovered I skipped the section on
> cond. That solves everything!

I think you are missing something here: the if macro in Scheme does not
require an else _expression_

(if a b)

is fine, b will be evaluated if a is not #f

your real problem is that the invocation of the procedure PrintDefined
will still evaluate to something even when you "do nothing" in the case
where the else _expression_ would be evaluated. Your \markup will barf if
the invocation of \PrintDefined evaluates to something that \markup is
not expecting.

Richard


>
>
> Many thanks,
> mattfong
>
> On Sat, Oct 17, 2020 at 9:27 AM Matthew Fong <oxengen@gmail.com>
> wrote:
> > Hello everyone,
> >
> > I've been digging into guile/scheme and LilyPond, and it doesn't
> > appear that else-statements can be empty. Any pointers would be
> > appreciated in advance.
> >
> > For the example below, I would prefer the else-statement here to do
> > nothing, rather than print an empty markup: \markup { "" }, as
> > doing so creates a small, but observable change in vertical
> > spacing.
> >
> > % Print markup if a symbol is defined
> > #(define-markup-command (PrintIfDefined layout props sym text)
> > (symbol? markup?)
> >     (if (defined? sym)
> >         ;; Do this if true
> >         (interpret-markup layout props
> >             #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> >     
> >         ;; How do I do nothing here? (empty statement preferred)
> >         (interpret-markup layout props
> >             #{ \markup "" #})
> >     )
> > )
> >
> > printInfo = 1
> > \markup \PrintIfDefined #'printInfo "Print this if symbol printInfo
> > is defined"
> >
> >
> > Many thanks,
> > mattfong
> >
> >

reply via email to

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