lilypond-user
[Top][All Lists]
Advanced

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

Re: How to get warnings for unused parts of a file?


From: David Kastrup
Subject: Re: How to get warnings for unused parts of a file?
Date: Fri, 01 Oct 2021 14:09:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

"Omid Mo'menzadeh" <omid.mnzadeh@gmail.com> writes:

> Thank you for your reply. This is working, but like this:
> main = #(if (not (defined? 'is-loaded-file))
>   #{
>     \score { \vocal }
>   #}
> )
>
> \main
>
> Any idea why it wouldn't work without defining the main variable? It's fine
> for me, but I don't get why the following snippet does not work for me:
> #(if (not (defined? 'is-loaded-file))
>   #{
>     \score { \vocal }
>   #}
> )

#... at the top level is executed but not interpreted.  That is because
it may contain things like assignments where the value is irrelevant.

If you want to force interpretation of the result, use $ instead of # .
In fact, apart from requiring a variable name instead of a Scheme
expression behind it $ and \ behave the same, so you could write $main
instead of \main , and you could write $(if (not (defined? ... .

There is a wrinkle here: what happens if the condition is not met?  In
that case, $... would want to interpret whatever value (if #f #f)
returns.  This value is undefined, but Guile specifically returns
*undefined* (a special value) in this case and LilyPond has been wired
to do nothing given

$*undefined*

so this happens to work as expected anyway.

-- 
David Kastrup



reply via email to

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