| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ LilyPond Scheme interfaces >> ] | ||
| [ < Interfaces for programmers ] | [ Up : Interfaces for programmers ] | [ Scheme functions > ] | ||
2.1 Lilypond code blocks
Lilypond code blocks look like
#{ Lilypond code #}
They can be used anywhere where you can write scheme code: the scheme reader actually is changed for accommodating Lilypond code blocks. When the Lilypond code block is being read, it is parsed superficially and replaced by a call to the Lilypond parser which is executed at runtime to interpret the Lilypond code block.
The point of the superficial parsing is the interpretation of $
signs which can be used for splicing in expressions from the surrounding
lexical scheme context (like let variables and function
parameters). $ can be used in the following ways:
-
$$ just passes a single
$to the Lilypond parser.-
$form will evaluate the Scheme form at runtime and splice its value as an identifier
\forminto the Lilypond parser. Depending on the value type, it may be interpreted as several different syntactic entities.-
#$form will evaluate the Scheme form at runtime and splice its value as a Scheme expression into the Lilypond parser.
-
#form Forms in Scheme expressions started with
#are read and parsed recursively for$signs. Those are treated as follows:-
#…$variable splices the value of the variable into the surrounding expression.
-
#…($ form …) splices the value of the form into the surrounding expression. As opposed to a Lilypond level
$form, you need to separate the form with a blank, making$be recognizable as a separate Scheme symbol.
A LilyPond code block may contain anything that you can use on the right side of an assignment. In addition, an empty LilyPond block corresponds to a void music expression, and a LilyPond block containing multiple music events gets turned into a sequential music expression.
| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ LilyPond Scheme interfaces >> ] | ||
| [ < Interfaces for programmers ] | [ Up : Interfaces for programmers ] | [ Scheme functions > ] | ||