On 5/7/23 14:23, Jean Abou Samra wrote:
Hi,

I'm adding back the list in CC. Please always keep it so that everyone can participate.


Le dimanche 07 mai 2023 à 10:45 -0400, dfro a écrit :
Jean,

Thank you, for the fast reply and the clear explanation! Perhaps, this insight could be put in the Learning Manual, 2.4.1 Organizing pieces with variables; or, somewhere else on using Scheme in Lilypond.

If I may also ask about the last example in that section of the manual:

<code start>

\version "2.24.1" myWidth = 60 % a number to pass to a \paper variable % (the unit is millimeter) myName = "Wendy" % a string to pass to a markup aFivePaper = \paper { #(set-paper-size "a5") } \paper { \aFivePaper line-width = \myWidth } { c4^\myName }

<code end>

Why can the # symbol be left off of the myWidth variable and other \paper block variables,




Only \markup mode is special. In normal mode, a number is interpreted as a number. In markup mode, a number is not interpreted specially so that \markup { 42 is the answer } works.



and why must the aFivePaper variable be enclosed within '\paper { ... }'?



Unlike TeX macros if you are used to that, LilyPond variables don't just "insert something in the input" at the point they are used. A variable is  variable in the true programming sense. It is associated with a value (which has a type). In this case, it does not work to do

aFivePaper = #(set-paper-size "a5")

because that calls set-paper-size immediately, not at the point where the variable is used, but at the point it is defined. This does nothing since set-paper-size doesn't have an effect outside of a \paper block. And since set-paper-size doesn't return a meaningful value, which in Guile means that it returns a dummy value called “*unspecified*”, your variable aFivePaper just ends up containing this dummy value.

With \paper, the variable contains a paper block, and LilyPond will merge it with the outer paper block if you reference the variable inside such a block.

Best,

Jean



Jean,
Thank you, for catching my omission of the CC to lilypond-user@gnu.org. I intended to reply to the group.

The use of variables for the \paper block makes more sense to me. However, I see that sometimes the numbers have no "#" before them, and sometimes they do as with:
inst-name-indent = #4.8
...and sometimes they do not, as with:
left-margin-title-page = 45
Also, setting true and false values use "##", as with:
ragged-last-setting = ##f

I am still not comprehending why the "#" is used sometimes and sometimes not. I am trying to grasp the nuances of how the lilypond language and the scheme language translate to each other.

Somewhere, in the documentation it talks about lilypond using the "#" to translate values into scheme language. Leaving off the "#" with numbers seems to break this rule. I also have a question about modes. Is normal mode where you input data outside a music block or without stating a mode explicitly, as with "\include "..."? I do not see it mentioned in "Notation Reference Manual, 3.1 Input modes".

Thank you, for the clear explanation of why \paper must be used for a "set-..." variable outside the main \paper block. That makes sense to me now.

I hope this is not too far off topic, but your "42 is the answer" reference led me to find this interesting article that is way over my head: https://news.mit.edu/2019/answer-life-universe-and-everything-sum-three-cubes-mathematics-0910.

Thank you, for the help.

Peace,
David

Reply via email to