Le 16 nov. 2009 à 20:32, David Kastrup a écrit : > With very few exceptions (about 2 or 3, one being the harp-pedal code), > all the commands appear to use the let-binding mechanism.
Indeed, when I introduced the property binding thing I changed consistently all markup command definitions. But it seems that I haven't documented it properly. Regarding the proper way to deal with the issue that you raise: Currently, a define-builtin-markup-command expression like: (define-builtin-markup-command (harp-pedal layout props definition-string) (string?) instrument-specific-markup ((size 1.0) (harp-pedal-details) (thickness 0.5)) "doc" (make-harp-pedal layout props (harp-pedals-parse-string definition-string))) expands into something like (among other things): (define-public (make-harp-pedal-markup layout props definition-string) "doc" (let ((size (chain-assoc-get 'size props 1.0)) (harp-pedal-details (chain-assoc-get 'harp-pedal-details props #f)) (thickness (chain-assoc-get 'thickness props 0.5))) (make-harp-pedal layout props (harp-pedals-parse-string definition-string)))) In the case of the harp-pedal markup, a nice thing to have would be: (define-public (make-harp-pedal-markup layout props definition-string) "doc" (let ((size (chain-assoc-get 'size props 1.0)) (harp-pedal-details (chain-assoc-get 'harp-pedal-details props #f)) (thickness (chain-assoc-get 'thickness props 0.5))) (let ((props (cons `((size . ,size) (thickness . ,thickness)) props))) (make-harp-pedal layout props (harp-pedals-parse-string definition-string)))) That is, when a default value is provided for a property, the property and its value (possibly the default one) are prepended to props, before evaluating the command body, so that subsequent searches in props find the default value set in the markup command. As you point out, this introduces consing, and most of the time, this is useless, as most of the commands do not call auxilary functions that in turn use the props argument. Moreover, I think that it may lead to confusion that the props argument is bound to another value than the one that was passed to the function. So imho, the way to handle it in the harp-pedal case is to explicitely prepend property-value pairs to props before calling make-harp-pedal: (define-builtin-markup-command (harp-pedal layout props definition-string) (string?) instrument-specific-markup ((size 1.0) (harp-pedal-details) (thickness 0.5)) "Make a harp pedal diagram..." (make-harp-pedal layout (cons `((size . ,size) (thickness . ,thickness)) props) (harp-pedals-parse-string definition-string))) Nicolas _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel