lilypond-user
[Top][All Lists]
Advanced

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

Variables as variables


From: Johan Vromans
Subject: Variables as variables
Date: Mon, 20 Jan 2014 16:00:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

In LilyPond terms, in

  namedMusic = { ... }

'namedMusic' is called a variable, identifier or macro.

Normal LilyPond behaviour is

  aaa = { c4 d e f }
  bbb = { a4 a a a \aaa b4 b b b }
  \score { \bbb }

This produces { a4 a a a c4 d e f b4 b b b } .

Now I want to re-use bbb with a different value of aaa. Like a real
variable as known from other programming languages.

  aaa = { c4 d e f }
  bbb = { a4 a a a \aaa b4 b b b }
  \score { \bbb }    % a4 a a a c4 d e f b4 b b b
  aaa = { f4 e d c }
  \score { \bbb }    % a4 a a a f4 e d c b4 b b b

Of course, this does not work. But I'm sure it can be made to work with
some schemish tweaks beyond my current capabilities.

This works, but it's not elegant.

  bbb = 
  #(define-music-function
      (parser location)
      ()
    #{
      a4 a a a \aaa b4 b b b
    #})

Putting the contents of bbb in a include file also works.

Do you have better (simpler, more elegant) suggestions?

-- Johan



reply via email to

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