lilypond-user
[Top][All Lists]
Advanced

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

Re: Copy variable by value in a current-module.


From: David Kastrup
Subject: Re: Copy variable by value in a current-module.
Date: Sat, 16 Oct 2021 12:14:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Robert Kubosz <kubosz.robert@gmail.com> writes:

> I want to make a copy of a variable defined in a separate file, but run in
> the same current-module.
> The copy I make is a copy-by-reference, and in result any modifications I
> apply to the copy also appear in the original.
> How do I make a copy-by-value in a current-module?
>
> More detailed example is attached to this email.
>
> Thanks in advance!
> Robert

Well, one thing to note is that LilyPond's "contract" is that you only
work with copies of music.  That is why something like

\trumpet-first

actually delivers a _copy_ of trumpet-first rather than the original.
Commands like \transpose then feel free to change their input as it is
either a mere copy or does not exist elsewhere under a different name.

So when you do Scheme programming, you need to work with copies.  The
easiest way, of course, is not to access variables directly but only
write music functions processing their input.

Since you can deliver this input in LilyPond mainly using \... it
automatically is either a copy or an original expression not used
elsewhere.

The other way is to use ly:music-deep-copy and it's not like this isn't
mentioned in the "LilyPond — Extending" guide of LilyPond.

-- 
David Kastrup



reply via email to

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