lilypond-user
[Top][All Lists]
Advanced

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

Re: calling a music variable using a Scheme function


From: Nicolas Sceaux
Subject: Re: calling a music variable using a Scheme function
Date: Fri, 19 Dec 2008 19:53:38 +0100

Le 19 déc. 08 à 14:12, Valentin Villenave a écrit :

Greetings Nicolas, hi everybody,

can someone tell me why the following snippet doesn't work?
(It's heavily based on Nicolas' functions -- and looked sooo promising...)

%%%%%%%%%%%
#(use-modules (ice-9 format))

toto = { c d c d }

includevar=
#(define-music-function (parser location name) (string?)
  (ly:parser-parse-string
    (ly:parser-clone parser)
    (format #f "\\~a"
            name))
  (make-music 'SequentialMusic 'void #t))

{ e1 \includevar #"toto" }

"Il y avait plus simple" (cf Bertrand Renard)

includeVar =
#(define-music-function (parser location name) (string?)
   (let ((music (ly:parser-lookup parser (string->symbol name))))
     (if (ly:music? music)
         music
         (make-music 'Music 'void #t))))

Your function does not work as you expect because it just returns an
empty SequentialMusic. Only the return value of the music function gets
"inserted" in the current music. Read scm/parser-ly-from-scheme.scm,
function parse-string-result.

Nicolas





reply via email to

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