Kees van den Doel <kvd...@gmail.com> writes: > Referring to > https://lilypond.org/doc/v2.22/Documentation/notation/substitution-function-syntax > > I don't understand this sentence explanating "...music...": > >>normal LilyPond input, using $ (in places where only LilyPond constructs > are allowed) or # (to use it as a Scheme value or music function argument > or music inside of music >lists) to reference arguments (eg. ‘#arg1’). > > The next section in the docs with examples has no example of use of '$'. > When should I use $?
In a nutshell, when # does not work. The syntax of an expression is decided before even looking at the value of the expression after # . So # in a certain place will only accept a certain type. For example, inside of { }, an expression started with # has to be a music expression, while $ allows expressions of type duration, pitch, post-event and probably others, integrating/converting them in the expected manner to music. $ first looks at the expression's type and then decides about its syntactic properties. Since the LilyPond expression parser works with lookahead for disambiguating expressions, that means that such expressions may be evaluated earlier than expected by the user. So generally # causes fewer syntactic surprises but is less flexible. Also it does not copy music expressions but takes them as-is. That can cause a difference in some cases. -- David Kastrup