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: Valentin Villenave
Subject: Re: New read/eval Scheme syntax inconsistent in handling existing code
Date: Sun, 4 Dec 2011 01:05:58 +0100

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 } }


This is a case where eval-string can be used (I'm not suggesting it's
proper coding practice, though -- in fact *even I* can see how ugly it
is):

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

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

#(define-public (make-simple-function token expr)
  (eval-string (format #f
   "(define-public ~a
      (define-music-function (parser location x) (ly:music?) ~a ))"
    token expr)))

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

{ \t { a b c } }


> The work I am doing may partly be complex, but the aim is to make
> Lilypond much more boring and predictable.  So if my changes drive you
> to more awkward solutions, that is a sign that there is something wrong.
> Either with my code, or your approach.  And I want to know about either,
> so that I have a chance to fix code and/or documentation.

I strongly suspect whatever awkwardness there may be here lies within
my coding practice (or lack thereof).

BTW, could you explain again why in the following example the variable
is overriden with # but not with $? I thought $ gave us the "old"
instant-evaluation behavior, but here it doesn't seem to be evaluated
before the music is parsed:

myvar = { b'4 }

$(display "this shouldn't be needed anyway")
$(eval-string "(define-public myvar #{ a'2 #} )" )

\new Staff \myvar

Thanks!

Valentin.



reply via email to

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