lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coding question about include-d tweak/function files


From: Urs Liska
Subject: Re: coding question about include-d tweak/function files
Date: Tue, 30 Jan 2018 17:02:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2



Am 30.01.2018 um 16:28 schrieb Kieren MacMillan:
Hello all,

For those who make heavy use of stylesheets and/or overrides and tweaks:
Do you have one large file? Several smaller files? One file per override?

Currently, I use "several smaller files", e.g.,

    /tweaks/dynamics.ily
    /tweaks/lyrics.ily
    /tweaks/spacing.ily

This looks like a reasonable grouping.


and so on.

But each of those files is pretty big (i.e., often containing many functions, many of which comprise a large number of lines). And I'm wondering if there's much of a performance hit when I load them multiple times (e.g., in a songbook, where the included file is brought in with each song that is included). That's especially inefficient if I'm only using one small function from the entire tweak file.

Thoughts and advice appreciated.

If this is a regular case I would look for a way to include them only once. Including them multiple times definitely doesn't make sense as the file will be completely parsed again and all the definitions just overwritten.

The approach I would use (doesn't necessarily mean it's the best one) is:
  • replace the \include with a new function
  • have that function add the included filels absolute path to some list
  • check that list before including the file

This is totally improvised, but with oll-core loaded you could do something along the lines of

% provide a storage space
\registerOption kieren.included-files #'()

% in a loading function ('to-include' is the file to check:
#(if (not (getOptionWithFallback `(kieren included-files ,to-include) #f))
     (begin
      (do-include-file to-include)
      (setChildOption '(kieren included-files) to-include #t))

just as a rough idea. Actually I don't know if the syntax of the functions is correct, but ...

Best
Urs

Thanks,
Kieren.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: address@hidden


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user


reply via email to

[Prev in Thread] Current Thread [Next in Thread]