[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: anonymous functions in define-grobs.scm
From: |
David Kastrup |
Subject: |
Re: anonymous functions in define-grobs.scm |
Date: |
Sat, 23 Nov 2013 07:12:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
"Keith OHara" <address@hidden> 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