Re: Can perl modules RECIPROCALLY 'use' one another?



Peter Scott wrote:

On Wed, 29 Jun 2005 14:17:50 +0000, Ignoramus4093 wrote:

Can I have a perl module

package A; use B;

and another module

package B;
use A;

would they be able to call one another's subroutines?

If both export subroutines, the second module won't get the first one's names exported because %INC has already been set when the first one was loaded. This is a known problem. It's not hard to write an example.

The general consensus is to not do cyclic dependencies between
exporting modules.  If you must, call the other module's routines
with package-qualified names.

Whilst I agree that cyclic dependancies are best avoided, it is not necessary to fully qualify names. It is sufficient to assign @EXPORT inside a BEGIN block.


BEGIN { our @EXPORT = qw( all those functions ) }

.



Relevant Pages

  • Re: flets in macros
    ... >> Exporting COLLECT and NEXT is preferable. ... you mean like LOOP does? ... If you use the package system then the user has the option of not ... But if your macro digs up ...
    (comp.lang.lisp)
  • RE: Modifying @INC
    ... More importantly the package 'package_name' should be exporting the ... This is how exporting is done. ... Subject: Modifying @INC ... the symbols to resolve the package namespace. ...
    (perl.beginners)
  • Re: Understanding CLOS Encapsulation
    ... exporting of symbols would allow the use of their "unqualified" symbol ... because I never said to load the arithmetic package. ... any code in accounting.lisp with two colens can get to any symbol in arithmetic.lisp. ...
    (comp.lang.lisp)
  • Re: export setf expansion
    ... > So, if I define a setf function in a package, how can I export it? ... The effects of exporting are that one can refer to the symbol using the ... Regardless of whether you export the symbol, in Common Lisp the ... underlying function, setf expander, etc. is always available for use. ...
    (comp.lang.lisp)
  • Re: flets in macros
    ... >> list or lists and binds COLLECT and NEXT to functions that allow the ... >> Now, my problem is that I'm defining this an a utility package, but I ... > Exporting COLLECT and NEXT is preferable. ... What happens when I want to use MAP-COLLECT? ...
    (comp.lang.lisp)