On Fri, Apr 1, 2022 at 6:43 PM Jean Abou Samra <j...@abou-samra.fr> wrote: > > Folks, > > Just a random thought in passing: I just wrote something of this kind > once again: > > (let ((elements (ly:music-property m 'elements)) > (element (ly:music-property m 'element)) > (articulations (ly:music-property m 'articulations))) > ...) > > (let ((padding (assoc-ref details 'padding)) > (common-Y (assoc-ref details 'common-Y))) > ...) > > (let ((padding (ly:grob-property grob 'padding) > (shorten-pair (ly:grob-property grob 'shorten-pair)) > (normalized-endpoints (ly:grob-property grob 'normalized-endpoints))) > ...) > > > Does anyone find a value in defining a macro for this? > > > \version "2.23.8" > > #(define-syntax-rule (fetch obj getter (sym ...) body body* ...) > (let ((evald-obj obj) > (evald-getter getter)) > (let ((sym (getter obj 'sym)) > ...) > body body* ...))) > { > c'1 > \tweak after-line-breaking > #(lambda (grob) > (fetch grob ly:grob-property (left-bound-info) > (fetch left-bound-info assoc-ref (common-Y X padding attach-dir) > (ly:message "common-Y=~a X=~a padding=~a attach-dir=~a" > common-Y X padding attach-dir)))) > \startTextSpan > c'1\stopTextSpan > }
It's shorter, but is it easier to understand and discover? Is the former code (which is somewhat verbose) a real barrier to getting coding/typesetting done? Over the years, I've become extremely wary of syntactic sugar: it adds an extra barrier to usage/development because everyone not only has to learn Scheme, they also have to learn the (lilypond specific) idioms involved. -- Han-Wen Nienhuys - hanw...@gmail.com - http://www.xs4all.nl/~hanwen