Something like this has also passed through my head.

What about use Test :ALL<&is &ok> or use Test :SOME-TAG<&foo &bar>.

so you can filter out what you want with arguments to the tag. This seems
to be better and more backwards-compy because with current rakudo use Test
:ALL<&is &ok> will still work (it will just do a normal :ALL import).

Zoffix++ for bringing this up.

also, I think that require could be adapted to work like this. Right now
require can only import from DEFAULT which seems like a needless
restriction (the design docs seem a little confused on this point).

require Test <&is &ok>, :SOME-TAG<&foo &bar>;

I think it's a good feature and importing would be much more consistent.

LL


On Sat, May 7, 2016 at 11:12 AM Zoffix Znet <perl6-bugs-follo...@perl.org>
wrote:

> # New Ticket Created by  Zoffix Znet
> # Please include the string:  [perl #128090]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=128090 >
>
>
> Currently, there seems to be no easy way to import only specific symbols
> from a module *at compile time*.
>
> For example, if I want to use a module that exports a whole ton of
> functions but I only one just one, I have to write something complicated
> like this:
>
> need Test;
> my &is := &Test::EXPORT::DEFAULT::is;
>
> This difficulty will result in many programmers trashing their namespaces
> out of convenience, resulting in hard-to-find bugs, especially when newer
> version of `use`d module introduces new subs.
>
> I propose we create another reserved import tag :SYM that will take a list
> of SYMbols we want to import, eg:
>
> use Test :SYM<&is &ok>;
>
> Although I'm ignorant of the implementation of the :ALL tag, I'd think
> implementing :SYM would be similar (you'd just grep for wanted symbols).
>
> Relevant IRC conversation:
> http://irclog.perlgeek.de/perl6/2016-05-07#i_12446098
>

Reply via email to