[Top][All Lists]

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

Re: Add \eval to Lilypond?

From: Erik Sandberg
Subject: Re: Add \eval to Lilypond?
Date: Sat, 04 Mar 2006 17:17:03 +0100
User-agent: Internet Messaging Program (IMP) 3.2.7

Citerar Alan Stern <address@hidden>:

> The facility for generating Lilypond code from within Scheme is
> fairly limited.  The #{ ... #} syntax only recognizes music
> expressions, so it can't be used in a \layout block, for instance.
> Is it possible to add a \eval primitive to Lilypond?  It could
> take as an argument either a literal string or a Scheme expression
> that returns a string, and then it would feed the contents of that
> string directly into the parser.
> As an example, we could put in a source file
> \eval #(if OutputMidi "\\midi { \\tempo 4 = 120 } " "")

Sounds like what you're looking for is a preprocessor. There will never be a
builtin preprocessor in lilypond, but you are free to use an external one if
you like (e.g. m4, gpp).

For music expressions, you could define an 'apply' music function:

apply = #(def-music-function (parser location statement music) (procedure?
  (let ((ls (ly:music-property music 'elements)))
   (statement ls)))

\apply #(lambda (x) (if (eq? 1 0) (car x) (cadr x))) { {c' d'} {e' f'} }

=> {e' f'}


reply via email to

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