On 08/26/2018 04:57 AM, Konstantin S. Uvarin wrote:
> Preface. `namespace::clean` is a module that erases symbols imported prior to
> its `use` line:
>
> package Foo;
> use Scalar::Util qw(blessed);
> use namespace::clean;
>
> blessed ($x); # ok
> Foo->blessed; # nope, no such method
>
> There are also namespace::autoclean and namespace::sweep (at least) in the
> same `namespace` namespace.
>
> Now after looking at namespace::clean I came up with a variation that limits
> imports to its enclosing scope:
>
> package Foo;
> # no traces of blessed exist
>
> sub uses_blessed {
> use namespace::local;
> use Scalar::Util qw(blessed);
>
> blessed ($x); # ok
> Foo->blessed; # nope, no such method
> };
>
> # no traces of blessed exist
>
> See more at http://prepan.org/module/nYiS6m8kTir
>
> However, I doubt about he name. Is it clear enough? Is it likely to clash with
> something else?
Because I'm already aware of "namespace::clean" et al., I could accurately
guess that "namespace::local" is related to cleaning, but I'll point out that
if one didn't know about those other modules, it may not be obvious from the
name alone what "namespace::local" is about.
On the other hand, nothing says the name of your module must be "obvious." And
maybe "namespace::" itself implies cleaning nowadays. Besides "namespace" and
"namespace::alias" which are for aliasing, the rest of the modules seem to all
be about cleaning.
Ultimately I think "namespace::local" is fine.
--
Charles McGarvey