lilypond-user
[Top][All Lists]
Advanced

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

Re: translation-type? vs. backend-type?


From: Lukas-Fabian Moser
Subject: Re: translation-type? vs. backend-type?
Date: Sun, 8 Aug 2021 21:35:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Hi David,
Ok, so then I remain unclear as to why the original code seemingly
worked with 2.12. But at the end of the day, I don't care that much:
'translation-type it is then, for what should be a \set'table context
property.
I repeat:

the change flagging the preexisting problem may possibly be

commit e44bc2cc48f9fb714603bdb5f8db532d55374087
Author: Neil Puttock <n.puttock@gmail.com>
Date:   Thu Apr 30 20:29:09 2009 +0100

      Add type-checking to \tweak.

in version 2.13.1

Sorry for being thick - the use of the word \tweak confused me.

I do not have the old development versions available, so my manual bisecting is very much on the coarse side. But I can confirm that:

For the following (WRONG!) definition of a context property

#(set-object-property! 'myprop 'backend-type? integer?)
#(set-object-property! 'myprop 'backend-doc "test property")

(A) LilyPond 2.12.3 complains about \set Staff.myprop = 42 but executes it (the property can be retrieved afterwards).
(B) LilyPond 2.12.3 does NOT complain about
  \context Staff {
    \applyContext
    #(lambda (ctx)
       (ly:context-set-property! ctx 'myprop 84))
  }
(and executes it).

LilyPond 2.14.0 still behaves like 2.12.3

LilyPond 2.14.2 complains about (A) and (B), but executes the assignments nevertheless.

LilyPond 2.16.2 still behaves like 2.14.2

LilyPond 2.18.0 complains about (A) and (B) and refuses to execute the assignments.

And of course, using a correct definition (using 'translation-type?), nothing changes between 2.12.3 and 2.22.0.


Code used for testing:

\version "2.12"

#(set-object-property! 'myprop 'backend-type? integer?)
#(set-object-property! 'myprop 'backend-doc "test property")

#(define show_myprop
  (lambda (ctx)
     (let ((myprop-ctx (ly:context-property-where-defined ctx 'myprop)))
       (format #t "Context: ~a\n" myprop-ctx)
       (if (ly:context? myprop-ctx)
           (format #t "myprop value: ~a\n\n"
                   (ly:context-property myprop-ctx 'myprop))))))


{
  \set Staff.myprop = 42
  c'4
  \applyContext #show_myprop

  c'4
  \context Staff {
    \applyContext
    #(lambda (ctx)
       (ly:context-set-property! ctx 'myprop 84))
  }
  c'4
  \applyContext #show_myprop
}

Lukas




reply via email to

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