lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting started with music functions


From: Aaron Hill
Subject: Re: Getting started with music functions
Date: Sun, 08 Mar 2020 17:30:43 -0700
User-agent: Roundcube Webmail/1.4.2

On 2020-03-08 3:57 pm, Stephan Schöll wrote:
It looks as if the "output" (return value) of a function can only be of
type "music", not "score", "book" aso, which would disappoint me. Am I
right? Or is there a way to define/change the type of the return value?

Music functions are for music.  Books and scores are not music.

Scheme functions are capable of returning arbitrary information. Scores, for instance, can be returned and handled properly. Books cannot.

=> David K., do you know why the parser balks at such a top-level ly:book?

An explicit call to print-book-with-defaults can work around the issue. But likely better is to use a void function, wrapping up all the functionality in a single construct.

%%%%
\version "2.19.84"
scoreFunc = #(define-scheme-function () () #{ \score { { b'4 } } #})
bookFunc = #(define-scheme-function () () #{ \book { \scoreFunc } #})

\scoreFunc % works
%\bookFunc % does not

#(print-book-with-defaults #{ \bookFunc #})

betterBookFunc = #(define-void-function () ()
  (print-book-with-defaults #{ \book { \scoreFunc } #}))
\betterBookFunc
%%%%


-- Aaron Hill



reply via email to

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