Jean Abou Samra <[email protected]> writes: >> Le 28 janv. 2023 à 08:01, Darren Ng <[email protected]> a écrit : >> >> [subject] How to define a macro that expands to a percussion "pitch"? > > > It may be worth noting that LilyPond does not have macros, only > variables and regular functions. Call me pedantic, but I think it is > helpful not to conflate the two.
It's a hybrid, actually. In Lispy terms, the difference between a function and a macro is that a function evaluates its arguments while a macro evaluates the result of executing the macro body on the unevaluated arguments. LilyPond evaluates a music/event/scheme/void function's body after reading its arguments but the reading/interpretation of the arguments is directed by the predicates. So a music/event/scheme/void function does evaluate some of its parts (the predicates) in order to direct the syntactic interpretation of its arguments. > There is no way in LilyPond to make a variable "just be replaced by > this code". Sometimes users get confused by this (I remember a > question about defining a chord modifier, which was similar to this > one). Instead, there are functions, as well as some other mechanisms > like drumPitchNames. In general, things are not purely functional but the categories and interpretation change around more by ad-hoc conditions than a cohesive macro mechanism. -- David Kastrup
