lilypond-devel
[Top][All Lists]
Advanced

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

Re: Proposal: change Grob.id to Grob.output-properties


From: Paul
Subject: Re: Proposal: change Grob.id to Grob.output-properties
Date: Fri, 16 Sep 2016 09:43:06 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 09/16/2016 01:10 AM, Urs Liska wrote:

Doesn't a conversion to

#`(id . ,(existing-function))

suffice? Otherwise just follow Carl's suggestion.

Hi Urs, Almost, but you have to add a lambda wrapper to pass along the implicit grob argument, and then there are other more challenging complications if the user has supplied a lambda expression or a variable that may be a string or a procedure. So most of the possibilities are non-trivial to impossible to handle well. See below.

Cheers,
-Paul


\version "2.19.42"

#(define procA (lambda (grob) (display "a ") "myid"))

#(define (procB grob) (display "b ") "myid")

procC = #(lambda (grob) (display "c ") "myid")

procE = "myid"

{
  % ORIGINALS

  \override NoteHead.id = #procA
  c1
  \override NoteHead.id = #procB
  c1
  \override NoteHead.id = \procC
  c1
  \override NoteHead.id = #(lambda (grob) (display "d ") "myid")
  c1
  \override NoteHead.id = \procE
  c1

  % RE-WRITES

  % these are fine (as long as the variable is a procedure):
  \override NoteHead.id = #(lambda (grob) `(id . ,(procA grob)))
  c1
  \override NoteHead.id = #(lambda (grob) `(id . ,(procB grob)))
  c1
  \override NoteHead.id = #(lambda (grob) `(id . ,(procC grob)))
  c1

  % to regex a lambda expression, I think you'd have to count matching
  % parens to arbitrary depth.  Not sure that is possible with regex...
  \override NoteHead.id =
  #(lambda (grob) `(id . ,((lambda (grob) (display "d ") "myid") grob)))
  c1

  % is \procE a string or a procedure?  No way to tell in convert-ly
  % and calling a string as if it were a procedure doesn't work
  % \override NoteHead.id = #(lambda (grob `(id . ,(procE grob))))
  c1
}





reply via email to

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