It's called a "race condition". I've seen it, but I try really hard to avoid it. Not always easy to do.
X uses Y, Y uses X. So let's go down the compiler's path for this. During the compilation of X, we see this statement "use Y;". So, we stop compiling X, load Y, and compile it. During that, we see the statement to "use X;". We stop and ... no, we see that X is already loaded. So we call X->import(), and continue. We finish compiling Y, including executing any of its global statements, and then go back to X and continue.
The solutions include:
- Breaking this relationship in one direction. Allow X to use Y, but not the other way around.
- Put all variables into functions. You'll need to watch out for infinite recursion if you leave your definitions as-is, I think. But I didn't fully grasp the code, so you may be ok.
- Put all common code into a common parent class. This is like the first option: breaking the relationship, except this does it in both directions. X uses W, and Y uses W, and W doesn't care about X nor Y.
- Put everything in the same compilation unit (module). :-)
- Others? I'm sure there are others. Regardless of what they are, they will usually be a redesign of some magnitude, large or small.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.