bug-lilypond
[Top][All Lists]
Advanced

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

Re: New read/eval Scheme syntax inconsistent in handling existing code


From: David Kastrup
Subject: Re: New read/eval Scheme syntax inconsistent in handling existing code
Date: Sun, 04 Dec 2011 17:06:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

Valentin Villenave <address@hidden> writes:

> On Fri, Dec 2, 2011 at 1:59 PM, David Kastrup <address@hidden> 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



reply via email to

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