[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: How to define a macro that expands to a percussion "pitch"?
From:       David Kastrup <dak () gnu ! org>
Date:       2023-01-28 15:51:14
Message-ID: 87v8kqu07h.fsf () fencepost ! gnu ! org
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic