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

Re: Exporter and subroutine circular dependencies between modules

Thread Previous | Thread Next
From:
Karen Etheridge
Date:
March 13, 2022 21:58
Subject:
Re: Exporter and subroutine circular dependencies between modules
Message ID:
CAPJsHfC=mfMDgsgCsZb6NXAv4bbzuSomFvt3LQyfyunCuvowyw@mail.gmail.com
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.


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
>

Thread Previous | Thread Next


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