Valentin Villenave <[email protected]> writes:

> On Fri, Dec 2, 2011 at 1:59 PM, David Kastrup <[email protected]> wrote:
>> I don't see why defmacro should have ceased working, so it might be
>> worth revisiting the problems you experienced.
>
> It's not defmacro that ceased working, it's just that I previously
> used the old ly:make-music-function syntax, which you changed when
> making music-functions optargs-able:
>
> #(use-modules (srfi srfi-39))
>
> #(define-public *tuplet-letter* (make-parameter "t"))
>
> #(defmacro make-simple-function (token expr)
>   (let* ((sym (string->symbol (primitive-eval token))))
>     `(define-public ,sym
>        (ly:make-music-function (list ly:music?)
>                                (lambda (parser location x)
>                                  ,expr)))))
>
> #(make-simple-function (*tuplet-letter*) #{ \times 2/3 $x #} )
>
>
> { \t { a b c } }

Try

#(use-modules (srfi srfi-39))

#(define-public *tuplet-letter* (make-parameter "t"))

#(defmacro make-simple-function (token expr)
  `(module-define! (current-module) (string->symbol ,token)
    (define-music-function (parser location x) (ly:music?)
     ,expr)))

#(make-simple-function (*tuplet-letter*) #{ \times 2/3 $x #} )


{ \t { a b c } }


Using module-define! beats primitive-eval.  If you want to know where it
is documented: it isn't.  But if you run a Guile program using
symbol-set! (which at one time was documented), it tells you that this
is deprecated and you should be using the module system instead.  And if
you try enough different commands with "module" in them on the Guile
command line...

I just asked on the Guile developer list whether this is somebody's idea
of a joke.  And I thought Lilypond documentation was bad.

-- 
David Kastrup

_______________________________________________
bug-lilypond mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to