develooper Front page | perl.perl5.porters | Postings from September 2022

Re: module loading built-in

Thread Previous | Thread Next
From:
Darren Duncan
Date:
September 17, 2022 10:53
Subject:
Re: module loading built-in
Message ID:
08ab6ecd-0832-ad85-24cc-8781d533e9e9@darrenduncan.net
On 2022-09-17 2:37 a.m., demerphq wrote:
> On Fri, 3 Sept 2021, 17:49 Ricardo Signes wrote:
>     For unexciting reasons, Module::Runtime has come up a few times on recent
>     PSC calls.  We talked about Module::Runtime, Class::Load, and I don't know
>     how many other related topics.
> 
>     We ended up with this question:  Isn't this something the core should provide?
> 
> I'm confused. The core does provide this. It's called require/use in eval.
> 
> I don't see what a builtin would add.
> 
> eval "use $module; 1"
> 
> Works fine.

Why?  Its because having to use string eval for something so simple and basic is 
a TERRIBLE design, a huge code smell.  The proposal of a proper basic 
runtime-defined load that DOESN'T use string eval is sorely needed.  This is 
insecure and error prone like SQL injection from straight interpolation of 
variables into the raw source when it should just be a plain value or argument. 
-- Darren Duncan


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