Hi Jan-Peter and David,
Am 20.06.2018 um 12:31 schrieb David Kastrup:
Urs Liska <li...@openlilylib.org> writes:
Am 20.06.2018 um 11:38 schrieb David Kastrup:
#(define-macro (define-my-custom-function . body)
`(define-music-function (mus) (ly:music?)
(let*
((elts (ly:music-property mus 'elements))
(cnt (length elts)))
,@body
mus)))
That's what one would call a pretty unhygienic macro since it messes
with a number of symbols/identifiers not specified by the user.
Hm, valid point. But I think it is worth it given the use case (I will
experiment and keep your point in mind, though).
By the way, you'll probably arrive at something like
#(define-macro (define-my-custom-function maybe-doc . body)
`(define-music-function (mus) (ly:music?)
,(if (string? maybe-doc) maybe-doc
"define-my-custom-function was here")
(let*
((elts ...
,@(if (string? maybe-doc) body (cons maybe-doc body)))
in order to let the user potentially specify a doc string.
Thanks for your help and explanation. I think I managed to get to a nice
point that will give users of the package a concise way to define
styling functions, without having to over and over repeat tedious and
potentially confusing code. (I'll post a link when it's ready and pushed).
Of course it's "unclean" because it will provide local bindings that are
totally not obvious from the user code, but I think (now more than
initially) that with sufficient documentation this is more than worth
the effort.
Urs
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user