develooper Front page | perl.perl6.users | Postings from September 2019

Re: Dynamic export/import of symbols into global namespace

Thread Previous
From:
Paul Procacci
Date:
September 20, 2019 23:59
Subject:
Re: Dynamic export/import of symbols into global namespace
Message ID:
CAFbbPug3=a33-Bg7_V39=196W0xJ8QP8G3YANHPJF-8HXL9ChA@mail.gmail.com
I happen to agree with both of you and have no problems with this.
I think me trying to be `too slick` in the world of subsets and `classes`
has possibly made this more complicated than it has to be.

For the record, I knew about `our` `my` `is export`, etc. but had the
damnest time trying to get that to apply to subsets.  I was obviously doing
something wrong.

Have a great one folks and thanks for the eyes.

~Paul

On Fri, Sep 20, 2019 at 4:01 PM William Michels <wjm1@caa.columbia.edu>
wrote:

> "Declaring a list of variables with lexical (my) or package (our) scope"
>
> https://docs.perl6.org/language/variables#index-entry-declaring_a_list_of_variables
>
> my:
> https://docs.perl6.org/syntax/my
>
> our:
> https://docs.perl6.org/syntax/our
>
> Paul, hoping the above points you in the right direction. FWIW, I
> agree with Vadim re: maintaining lexical scope at the highest possible
> level.
>
> Best, Bill.
>
>
>
>
> On Fri, Sep 20, 2019 at 12:38 PM Vadim Belman <vrurg@lflat.org> wrote:
> >
> > Why would you need this? Mangling with things outside of your lexical
> scope isn't one of the best ideas. Perhaps, you could achieve same result
> with simply exporting the subset from the module using selective export
> with `is export(:tag)`?
> >
> > Best regards,
> > Vadim Belman
> >
> > On Sep 20, 2019, at 3:32 PM, Paul Procacci <pprocacci@gmail.com> wrote:
> >
> > As the subject suggests, I'd like to dynamically export/import symbols
> from a source file into the global scope of the program.  How would one
> accomplish this?
> >
> > Given the below, it yields an error _which I expect_.  How do I
> dynamically pull in the subset 'What'?
> >
> >
> > File: Testing.pm6
> > --------------------------
> >
> > subset What of Str;
> > class Testing {}
> >
> >
> >
> > File: main.pl
> > --------------------------
> > {
> > my $c = 'Testing';
> > require ::($c);
> > my $t = ::($c).new;
> > }
> >
> > my What $x = 'Blah'
> >
> >
> > --
> > __________________
> >
> > :(){ :|:& };:
> >
> >
>


-- 
__________________

:(){ :|:& };:

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About