develooper Front page | perl.perl6.users | Postings from March 2021

Re: Find Packages with prefix ...

Thread Previous | Thread Next
Ralph Mellor
March 7, 2021 14:45
Re: Find Packages with prefix ...
Message ID:
Afaik, existing mechanisms (`use`, `zef`, `-I`) support the following:

> Within this namespace, I would ideally designate
> SuperDuperProgram::Modules to be the namespace
> that modules would live under.

> These modules would have their own git repos and
> depend on SuperDuperProgram being installed.

> I'd like the main program to perform a prefix search of
> installed modules with that namespace as a prefix

> load said modules it finds


Aiui the above are freely available without you lifting a finger.

This bit is different:

> perform callbacks that I would designate as being required
> to successfully load the module

Quoting S11:

> It must be possible for any compilation unit to be separately
> compiled without knowledge of the lexical or dynamic context
> in which it will be embedded,

I think this means a *callback* would have to occur *after* the
`use` statement. It sounds to me like, once you initiate a load,
all that can happen is that the module is either not found, or it
fails to compile, or it loads successfully on its own terms based
on its own code.

If I'm right about that, this control of the success of loading
becomes the problem you need to solve.

Perhaps you can use arguments in the `use` statement?

Then the module's code could make use of those arguments to
decide whether it "succeeds" or not (as a concept separate from
whether it *technically* succeeds in the sense of *loading*). And
if it does *not* succeed in this non-technical sense, it makes sure
it does nothing, and uses its EXPORT routine to export nothing.

So it loads, but has no effect other than to have registered that
a module of that name has loaded.

It sounds like that's unfortunately not good enough for what you want.

In which case I'm out of ideas for right now.

love, raiph

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About