Thanks for quick answers, Jean and David! The function "ly:music-deep-copy" is the solution I was looking for :-)
> module-ref and module-set! are useful for dealing with variables of which the name is not known in advance. Actually, in my case I don't know in advance the name of a variable which value I want to copy, that's why I used the module-ref function. In the example presented to you I used a symbol, because I wanted to keep the example as simple as possible. > It assumes that the #{ c' des' #} part comes from something programmatically, Yes, that's the reason. > 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 You know, David, I just got lost. I wish I had more time to work with my project. Many many thanks! Robert sob., 16 paź 2021 o 12:14 David Kastrup <d...@gnu.org> napisał(a): > Robert Kubosz <kubosz.rob...@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 >