Re^2: repeated use of module and EXPORT
by shmem (Chancellor) on May 23, 2008 at 19:34 UTC
|
Why not? Happens all the time. My love and I require each other in any load order; that's just fine.
What matters in mutual including is the state of the including module - it is not yet compiled in its entirety.
If the included module relies on data structures of the including module which will be set up at run time
in there, it won't get those. So, each module must be set up proper to be used by the other one, then use
the other one.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] |
Re^2: repeated use of module and EXPORT
by rpelak (Sexton) on May 23, 2008 at 15:56 UTC
|
That is a common statement to not have each use the other... but there is nothing wrong with doing so... and in this case it makes good sense...
In the real case, libs and dbg... I would have to copy various libs subs into the dbg module to avoid the loop. which would cause duplication of code, which is also a never do...
And since the two modules come together it is okay for them to rely on each other.
in a certain sense, dbg is like a class that is being inherited, and libs is just a general module of subs to be used by anyone. So for them to be interdependent isn't really a problem for the design... | [reply] |
|
|
How about having a third package, let's call it util, that contains the shared code. Include util in both libs and dbg, and you no longer have the loop.
| [reply] |
|
|
... and you no longer have the loop.
There is no loop. Each piece of code gets compiled once. As one piece of code uses the other one, it gets what is defined
at that moment of compilation, that's all - perl won't loop switching compilation from one to the other and from the other
to the one and back and forth again over and over.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] |
|
|
|
|
My reply to this doesn't seem to be showing up, but I will try one last time...
That doesn't work out. In the real case the Z module is a dbg module, and all modules use dbg... so the new module would also use dbg, and the loop would still be present.
| [reply] |
|
|
Yes there is - you don't know how to make it work.
Listen to MidLifeXis suggeststion, and put the common functions in a another module.
| [reply] |
|
|
Actually, no that still doesn't work. The Z module is a dbg module. Every function no matter where it is in any module will still have some dbg code in it. So you would still have the loop of dbg calling the new module and the new module calling dbg.
| [reply] |