lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to define a macro that expands to a percussion "pitch"?


From: David Kastrup
Subject: Re: How to define a macro that expands to a percussion "pitch"?
Date: Sat, 28 Jan 2023 16:51:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Jean Abou Samra <jean@abou-samra.fr> writes:

>> Le 28 janv. 2023 à 08:01, Darren Ng <un1gfn@gmail.com> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]