develooper Front page | perl.module-authors | Postings from March 2022

Re: Exporter and subroutine circular dependencies between modules

Thread Previous
From:
David Christensen
Date:
March 14, 2022 01:33
Subject:
Re: Exporter and subroutine circular dependencies between modules
Message ID:
e664ea78-de46-9acd-d659-06d0f800eb6e@holgerdanske.com
> On Sun, Mar 13, 2022 at 1:14 PM David Christensen <dpchrist@holgerdanske.com>
> wrote:
> 
>> module-authors:
>>
>> I have been wrestling with the Exporter module and subroutine circular
>> dependencies between modules for a number of years.  I have yet to find


On 3/13/22 14:57, Karen Etheridge wrote:
 > I haven't looked at your code, but I assume what you're doing is 
exporting
 > a sub from each module, and something in each of those modules is calling
 > each of those subs in turn, using the exported symbol. This is indeed an
 > unresolvable circular dependency because unqualified sub names must be
 > resolved at compile (i.e. "use" or BEGIN{}) time.
 >
 > One solution is to not import all the symbols -- break the cycle by 
simply
 > 'use'ing a module without importing its subs, and call that sub by its
 > fully-qualified name (e.g. Foo::foo() rather than foo()), which only 
needs
 > to be resolvable at runtime.


Thank you for the reply.  :-)


I am looking for a solution that allows me to call module subroutines 
via imported names, rather than via fully-qualified names.


David

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About