develooper Front page | perl.perl5.porters | Postings from October 2021

Re: module loading built-in

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
October 3, 2021 18:39
Subject:
Re: module loading built-in
Message ID:
c059564c-e59e-4973-9345-121c793804ff@beta.fastmail.com
On Fri, Sep 3, 2021, at 3:26 PM, Karen Etheridge wrote:
> On Fri, Sep 3, 2021 at 10:49 AM Dan Book <grinnz@gmail.com> wrote:
>> 
>> haarg was working on a Module::Runtime replacement that has this capability with a function called "try_require_module", which returns true on success, false on not found or insufficient version, and an exception on other errors. I think it is a great API, but unfortunately has not been put through the rigors of CPAN workshopping yet.
> 
> IMO the toolchain gang should take on the goal of producing an RFC. Graham has done much of the work (investigative, as well as code) on this already so we should be able to get to that point "soon".

Graham wrote into this thread, but I don't think it seems like we're expecting an RFC, so I'd rather this not stagnate.

It seems like the thrust of Graham's post was "yes, a `load STRING` would be useful, but we want to distinguish between kinds of failure."  I agree, and I think we want that from `require`, too, and I also think that "an exception system would solve this" is the kind of thing that can stymie a lot of stuff because it wants to plumb stuff into all parts of Perl.

Instead, I propose that the next step here is to provide a load-at-runtime built-in that expects the name of a module and dies on error.  At some future time, if we overhaul exceptions, we can fix both it and "require" then.  In the meantime, I don't think it's economical to make load-at-runtime wait on an exception overhaul.

Thoughts?  Shall I write the RFC?

-- 
rjbs
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