X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fcontributor%2Fprogramming-work.itexi;h=99dc79da4a9c6a274aa30ca8e52c68c94ccdc3f2;hb=ee9caedb7764cfd240f0212984ce2218e865367b;hp=fd850f4b1ca9f349cd749e6db77994d65adb3759;hpb=df6ed3aed7aeff7d47cbf44bd54d74e17a41eaf0;p=lilypond.git diff --git a/Documentation/contributor/programming-work.itexi b/Documentation/contributor/programming-work.itexi index fd850f4b1c..99dc79da4a 100644 --- a/Documentation/contributor/programming-work.itexi +++ b/Documentation/contributor/programming-work.itexi @@ -1134,18 +1134,17 @@ in has been declared. For example, if you are working on routines called by @var{print-book-with} in @file{lily-library.scm}: @example -(define (print-book-with parser book process-procedure) - (let* ((paper (ly:parser-lookup parser '$defaultpaper)) - (layout (ly:parser-lookup parser '$defaultlayout)) - (outfile-name (get-outfile-name parser))) +(define (print-book-with book process-procedure) + (let* ((paper (ly:parser-lookup '$defaultpaper)) + (layout (ly:parser-lookup '$defaultlayout)) + (outfile-name (get-outfile-name book))) (process-procedure book paper layout outfile-name))) -(define-public (print-book-with-defaults parser book) - (print-book-with parser book ly:book-process)) - -(define-public (print-book-with-defaults-as-systems parser book) - (print-book-with parser book ly:book-process-to-systems)) +(define-public (print-book-with-defaults book) + (print-book-with book ly:book-process)) +(define-public (print-book-with-defaults-as-systems book) + (print-book-with book ly:book-process-to-systems)) @end example At this point in the code you could add this to set a breakpoint at @@ -1376,7 +1375,7 @@ scripts/auxiliar/update-with-convert-ly.sh If you did an out-of-tree build, pass in the relative path: @example -BUILD_DIR=../build-lilypond/ scripts/auxiliar/update-with-convert-ly.sh +LILYPOND_BUILD_DIR=../build-lilypond/ scripts/auxiliar/update-with-convert-ly.sh @end example @@ -2558,22 +2557,24 @@ this will display OBJ through GUILE. @subsection Music functions and GUILE debugging Ian Hulin was trying to do some debugging in music functions, and -came up with the following question +came up with the following question (edited and adapted to current +versions): HI all, I'm working on the Guile Debugger Stuff, and would like to try debugging a music function definition such as: @example -conditionalMark = #(define-music-function (parser location) () -    #@{ \tag #'instrumental-part @{\mark \default@}  #@} ) +conditionalMark = +#(define-music-function () () + #@{ \tag instrumental-part @{\mark \default@} #@} ) @end example -It appears conditionalMark does not get set up as an +It appears @code{conditionalMark} does not get set up as an equivalent of a Scheme @example -(define conditionalMark = define-music-function(parser location () ... +(define conditionalMark = define-music-function () () ... @end example @noindent @@ -2587,25 +2588,54 @@ although something gets defined because Scheme apparently recognizes later on in the file without signalling any Guile errors. However the breakpoint trap is never encountered as -define-music-function passed things on to ly:make-music-function, -which is really C++ code ly_make_music_function, so Guile never -finds out about the breakpoint. +@code{define-music-function} passed things on to +@code{ly:make-music-function}, which is really C++ code +@code{ly_make_music_function}, so Guile never finds out about the +breakpoint. + + +The answer in the mailing list archive at that time was less than +helpful. The question already misidentifies the purpose of +@code{ly:make-music-function} which is only called once at the +time of @emph{defining} @code{conditionalMark} but is not involved +in its later @emph{execution}. + +Here is the real deal: + +A music function is not the same as a GUILE function. It boxes +both a proper Scheme function (with argument list and body from +the @code{define-music-function} definition) along with a call +signature representing the @emph{types} of both function and +arguments. -Han-Wen answered as follows: +Those components can be reextracted using +@code{ly:music-function-extract} and +@code{ly:music-function-signature}, respectively. -You can see the definition by doing +When LilyPond's parser encounters a music function call in its +input, it reads, interprets, and verifies the arguments +individually according to the call signature and @emph{then} calls +the proper Scheme function. + +While it is actually possible these days to call a music function +@emph{as if} it were a Scheme function itself, this pseudo-call +uses its own wrapping code matching the argument list @emph{as a +whole} to the call signature, substituting omitted optional +arguments with defaults and verifying the result type. + +So putting a breakpoint on the music function itself will still +not help with debugging uses of the function using LilyPond +syntax. + +However, either calling mechanism ultimately calls the proper +Scheme function stored as part of the music function, and that is +where the breakpoint belongs: @example -#(display conditionalMark) +#(set-break! (ly:music-function-extract conditionalMark)) @end example -noindent -inside the @file{.ly} file. - -The breakpoint failing may have to do with the call sequence. See -@file{parser.yy}, run_music_function(). The function is called directly from -C++, without going through the GUILE evaluator, so I think that is why -there is no debugger trap. +will work for either calling mechanism. @node Articulations on EventChord @subsection Articulations on EventChord