On 2021-06-29 12:45 pm, Carl Sorensen wrote:
I believe that the logical implications of side-effects are not very
concerning when local variables are set!, so there's probably very
little or no downside to the set!s in Aaron's code.  In fact, it's
possible that Aaron's code will use less heap space by re-using class
instead of adding a new variable grob-class-name.  But I can't help
myself; I want to avoid the grief  Sussman would give me over two
unneeded set! calls.....

I prefer that pattern of set! calls because it helps you avoid nesting S-expressions too deeply, which I feel greatly improves readability and maintainability. It is the same reason I bothered to define the add-class-name procedure, so that it would not be nested within the engraver definition itself, better separating concerns.

Additionally, I have taken flack for pushing some of the more functional elements of Scheme programming. (Mention the word "lambda" once, and everyone assumes you are a pure functional zealot.) Regardless, I have tended to favor a more imperative approach lately, something that is likely to be more consumable for users of LilyPond.


-- Aaron Hill

Reply via email to