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 <rich...@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 <oxen...@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