lilypond-user
[Top][All Lists]
Advanced

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

Re: Creating a callback with an additional argument?


From: Marc Hohl
Subject: Re: Creating a callback with an additional argument?
Date: Sun, 26 Sep 2010 21:00:25 +0200
User-agent: Thunderbird 2.0.0.24 (X11/20100317)

Reinhold Kainhofer schrieb:
Am Sonntag, 26. September 2010, um 20:19:28 schrieb Marc Hohl:
is it possible to create a callback with an additional argument?

Yes, that's possible. I'm using it for example for the glyph-flag flag style.



I tried

#(define-public (my-callback string grob)
...
..
)

#(define-public ((glyph-flag flag-style) stem-grob)
  "Simulates the default way of generating flags: look up glyphs
   flags.style[ud][1234] from the feta font and use it for the flag stencil."
  (create-glyph-flag flag-style "" stem-grob))

Notice that the function name and the first argument are in parenthesis. Think of it like glyph-flag being a function that returns a function.
Ah, that's interesting - I understood Wilbert Berendsen's lambda construct
(and wondered why I didn't came up with that myself ...) but this is new to me. Great!
and wanted to call it by

\override Notehead #'stencil = #my-callback #'foo'

#(define-public ((my-callback string) grob)
  .....
)

\override Notehead #'stencil = #(my-callback 'foo)
Thank you!

Marc
Cheers,
Reinhold




reply via email to

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