"Keith OHara" <[email protected]> writes: > Near the top of 'define-grobs.scm' it says > ;;;; WARNING: don't use anonymous functions for initialization. > and I am wondering why. > > I suspected it was to avoid storing a function body in every instance of the > type of grob that might have an anonymous function as one of its default > properties. > But then I see that we use > (X-offset . > ,(ly:make-simple-closure > `(,+ > ,(ly:make-simple-closure > (list ly:break-alignable-interface::self-align-callback)) > ,(ly:make-simple-closure > (list ly:self-alignment-interface::x-aligned-on-self))))) > > rather than the simpler > (X-offset . > ,(lambda (g) > (+ (ly:break-alignable-interface::self-align-callback g) > (ly:self-alignment-interface::x-aligned-on-self g)))) > > which follows the rule in the WARNING, but does not seem that it would > reduce the storage needed in each grob.
That's not a rule for avoiding storage: grobs are not copied "deeply", and if they were, the anonymity of a function would not make a difference. My personal guess is that anonymous functions look like garbage and/or don't print nicely or at all in EG. Neither does the definition of X-offset using make-simple-closure (regarding "nicely"), see <URL:http://lilypond.org/doc/v2.16/Documentation/internals/accidentalsuggestion>. I mean, ugh. Possibly the EG generator complains when not finding a name for a function? -- David Kastrup _______________________________________________ lilypond-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-devel
