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