I can store variables with symbol-list? names like so:

   \version "2.19.80"

   my.note.one = { c'4 }
   my.note.two = { d'2 }

   {
      \my.note.one
      \my.note.two
      \my.note.one
   }

It is also possible to store functions in such variables:

    my.function =
    #(define-music-function ()()
      #{ c'4 #})

However, it is not possible to *call* the function like retrieving the value above:

    {
      \my.function
    }

yields "warning: ignoring non-music expression".

But I can do

    {
      #(#{ \my.function #})
    }

My impression is that "\my.function" by itself retrieves the value, i.e. the stored function, rather than applying it, while the last example goes around some corners to actually doing what I want.

I would like to find a smoother syntax to invoking functions like this because I'd like to explore the possibility to create a namespace of functions like \mylib.function-one, \mylib.function-two etc. But it would only make sense if there's a really easy end-user syntax, and to get there I'd have to first understand what is actually happening (in the parser?) when \my.function is encountered.

I didn't see where this (rather new) option is documented, so I'd be happy about any pointers or even examples.

Thanks
Urs

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to