in reply to Sharing variables and subroutines between modules: unexpected warnings and errors.

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:

  • Comment on Re: Sharing variables and subroutines between modules: unexpected warnings and errors.