Thanks, Carl. I was hunting for a music void before, and missed it. I have several uses for it.
I'm very fuzzy on using parser vs. (ly:parser-clone parser). I have a pretty good guess what it means technically at the low level (presumably parser is an object with state, and the clone gives a separate local state). I chose the clone empirically to avoid a segmentation fault. But, ... I now find that my solution seems to evaluate LilyPond variable definitions variable = { ... } in an acceptable context. But Scheme variable definitions: #(define variable ...) appear to define the variable only in some limited scope, so that they aren't available globally as they would be with \include instead of \includeIfAbsent. It's not clear to me what part of the syntax is generating that scope, and it could even be the cloning of the parser. I found define-public-toplevel, which can be used in the included file (and probably should be in most cases, for greater robustness), but I'd still like to make \includeIfAbsent work for legacy include files. And, of course, every error of this sort that I find, springing from my ignorance rather than just a little programming blunder, increases my hope that someone with fuller knowledge will point out some challenging test cases. Cheers, Mike O'D. Carl Sorensen wrote: > > On 2/11/10 11:05 AM, "Michael J. O'Donnell" <michael_odonn...@acm.org> > wrote: > > >> Here's what I *now think* is correct code O:-) : >> >> includeIfAbsent = >> >> #(define-music-function (parser location fileName) (string?) >> >> (let ((guardName (string-append "Already Got " fileName))) >> >> (if (not (defined? (string->symbol guardName))) >> (begin >> >> (primitive-eval (list 'define (string->symbol guardName) #t)) >> >> (ly:parser-parse-string (ly:parser-clone parser) (string-concatenate >> (list "\\include \"" fileName "\""))) >> >> #{ #} >> > > When I see #{ #}, I suspect that instead of using the substitution syntax, > you should be using void music functions (i.e. your return should be > (make-music 'SequentialMusic 'void #t)). This is the empty music you refer > to below. > > You can read more about void music functions in Notation Reference 6.1.5 for > version 2.12 or in Extending LilyPond 2.1.5 for version 2.13. > > Thanks, > > Carl > > > _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel