[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to include a file just once?
From: |
Reinhold Kainhofer |
Subject: |
Re: How to include a file just once? |
Date: |
Fri, 22 Jan 2010 02:02:43 +0100 |
User-agent: |
KMail/1.12.4 (Linux/2.6.31-17-generic; KDE/4.3.4; i686; ; ) |
Am Freitag, 22. Januar 2010 01:19:39 schrieben Sie:
> >> \include "../../pop-chords.ly"
> >> \include "../../paren-2.ly"
> >
> > And now imagine that both of the included files include some other
> > file
> > blahblah.ily, which adds or removes some engraver to/from a
> > context. The
> > engraver will be added twice, which is a very good way to produce
> > lilypond
> > crashes...
>
> Interesting. I don't think it would occur to me to structure
> includes recursively in the first place.
No, I'm not talking about recursive includes. Rather, you have a common
include files with definitions for all your packages, and all your other
include files need to include these base definitions.
E.g. image you have two include files: modern-usage.ly and critical-
report.ily. In both of them you need the same functionality, so you move the
common code to e.g. base-definitions.ily:
-) base-definitions.ily:
% Some definitions, needed in all your include files
\layout {
\context {\Staff
% Add / remove some engravers here
}
}
-) modern-usage.ily:
\include "base-definitions.ily"
% Here, provide some functions for modern notation practice, which depend on
% the definitions from base-definitions.ily
-) critial-report.ily:
\include "base-definitions.ily"
% Here, provide some functions for critical reports, which depend on
% the definitionsfrom base-definitions.ily
Now, in your score, you sometimes need only modern-usage.ily, but sometimes
you need both:
\include "modern-usage.ily"
\include "critical-report.ily" % <= Oops, usually crashes during processing
As you see, the second include includes the base-definitions.ily a second
time, so the engravers are added twice, and some engravers are very sensitive
and will crash in that case...
There's no recursion in here, just some straightforward package structure with
a base packages and two packages building on that base Package...
Cheers,
Reinhold
--
------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
* Financial & Actuarial Math., Vienna Univ. of Technology, Austria
* http://www.fam.tuwien.ac.at/, DVR: 0005886
* LilyPond, Music typesetting, http://www.lilypond.org