1.2.2 LilyPond variables

LilyPond variables are stored internally in the form of Scheme variables. Thus,

twelve = 12

is equivalent to

#(define twelve 12)

This means that LilyPond variables are available for use in Scheme expressions. For example, we could use

twentyFour = #(* 2 twelve)

which would result in the number 24 being stored in the LilyPond (and Scheme) variable twentyFour.

The usual way to refer to LilyPond variables is to call them using a backslash, i.e., \twentyFour (see LilyPond Scheme syntax). Since this creates a copy of the value for most of LilyPond’s internal types, in particular music expressions, music functions don’t usually create copies of material they change. For this reason, music expressions given with # should usually not contain material that is not either created from scratch or explicitly copied rather than directly referenced.

Other languages: deutsch, español, français.
About automatic language selection.

LilyPond — Extending v2.19.41 (development-branch).