|
From: | Paul Scott |
Subject: | Re: 2.25.2 optional fine endings |
Date: | Mon, 13 Mar 2023 14:19:53 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 |
Le lundi 13 mars 2023 à 13:04 -0700, Paul Scott a écrit :
I've read your wonderful scheme documentation. I'm still struggling to make sense of Aaron's simple code
\fixed c' {
c1
\set Score.repeatCommands = #((volta ,voltaFine)) c4 d c2 \bar "|." \set Score.repeatCommands = #
((volta #f) (volta ,voltaCont))
f4 g a b
\set Score.repeatCommands = #'((volta #f))
}I'm extremely familiar with a number of programming languages including Forth. If one of you could say more about what the line:
\set Score.repeatCommands = #`((volta #f) (volta ,voltaCont))
does and how it relates with\set Score.repeatCommands = #(list(list 'volta voltaCont))
I might be able to go farther.
TIA for any more help with this,
The format of
repeatCommands
is a list where each element is itself a list. The first element of each sublist (element of the main list) is a "command", namely a symbol, which can bevolta
,start-repeat
orend-repeat
.
If the command is
volta
, LilyPond expects one remaining element in the sublist, which can be
- a markup, to start a volta bracket and print this text under it (note that a simple string is also a valid markup),
#f
(the boolean false), to end a volta bracket previously started with the first form.If the command is
start-repeat
, it prints a start repeat bar line.If the command is
end-repeat
, it prints an end repeat bar line.The _expression_
#(list (list 'volta voltaCont))
uses the
list
function to create a list with one element inside. That element is(list 'volta voltaCont)
, which is itself a list with two elements,'volta
andvoltaCont
. The first element is a quoted symbol, so it's not evaluated and remains as a symbol. The second element is also a symbol but without a quote. Since symbols are not self-evaluating, but evaluate by looking up variables, this reads the value of thevoltaCont
variable. So you havelist | list element 1: | list | list element 1: the symbol volta | list element 2: the markup contained in the variable voltaCont
which matches the form for a repeatCommands with one command, "volta", starting a volta bracket with the text contained in the variable "voltaCont".
The _expression_
#`((volta #f) (volta ,voltaCont))
is a quasiquote. Since a quasiquote is “almost a quote”, it means that Scheme looks literally at what _expression_ you have entered, rather than evaluating it. Because of the parentheses, it's a list. That list contains two sublists. The first one is
(volta #f)
. Again, it's quoted, so it's not evaluated. (If it were evaluated, it would look up the function “volta” and apply it to the boolean#f
.) That list is made of the symbolvolta
and the boolean#f
.The second sublist is
(volta ,voltaCont)
. Again, it's quoted, so not evaluated. The first element isvolta
, a symbol. The second element has an unquote on it (the comma), so it does get evaluated. It's a symbol,voltaCont
, and symbols evaluate by looking up variables, so it gets the value ofvoltaCont
and inserts that markup into the sublist.The result is
list | list element 1: | list: | | list element 1: the symbol volta | | list element 2: the boolean #f | list element 2: | list: | | list element 1: the symbol volta | | list element 2: the markup contained in the variable voltaCont
and it matches the format of
repeatCommands
for two commands: ending a previously started volta (the first element) and starting a new one (the second element).Did it help to read it very verbosely like this?
Probably. I have no excuse for not getting it after this. I won't be able to spend any more time on for a few hours.
Thank you very much,
Paul
[Prev in Thread] | Current Thread | [Next in Thread] |