develooper Front page | perl.perl5.porters | Postings from August 2023

Re: Lexically using modules

Thread Previous | Thread Next
From:
Robert Rothenberg
Date:
August 1, 2023 20:03
Subject:
Re: Lexically using modules
Message ID:
ddadb131-e72c-f1a8-ed23-2629f82bdf3b@cpan.org
Apologies for being late to reply.

On 16/07/2023 13:58, Ovid wrote:
>
> It would be nice to have some kind of pragma like:
>
>     use feature 'use'; # rubbish name!
>
> And with that, none of your code could use a module that is not 
> explicitly used or required.

A bit late to this, but maybe call the feature "strict_namespaces"?

I am assuming that code should not refer to another namespace that has 
been explicitly used?

> However, given string eval and other tricks, that might be hard to do. 
> So maybe:
What about accessing things in another namespace with something like 
Package::Stash?

What about packages like Getopt::Long::Descriptive or Data::Enum that 
create objects in ad hoc namespaces? Will this pragma prevent code from 
using those objects?

What is I pass a reference to something in another namespace to code 
that uses this feature? I would still expect it to work.

What about modules that use a a singleton, e.g. a state variable that is 
shared by everything that uses it? If modules are imported into isolated 
namespaces, will those singletons work?




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