develooper Front page | perl.perl6.users | Postings from August 2020

Re: Re-exporting modules that export operators...

Thread Previous | Thread Next
From:
Ralph Mellor
Date:
August 15, 2020 23:03
Subject:
Re: Re-exporting modules that export operators...
Message ID:
CAPLR5Sc9-A6cYKkXZtP2BdAuzbhzik2NJcKVNwGmiGwGqc5hvg@mail.gmail.com
The SO you quote includes an operator. So that's not the problem.

The SO is written by jnthn. It doesn't get more authoritative than that.

"Cannot import symbol '%?LANG' from 'Graphics::Shapes', because it
already exists in this lexical scope."

Your export code is attempting to export `%?LANG`, but that already
exists in every lexical scope. (`%?LANG`:is the language braid -- the
dictionary of sub-languages that collectively constitute the Raku language.)

So don't do that.

In the SO jnthn demonstrates stripping out `$_`. You need to also strip
out any other lexicals that you don't mean to export. So use a `say` to
see what lexicals you're currently exporting and then grep out any that
you don't mean to export.

Perhaps share your code if you can't get it to work.

--
love, raiph

On Fri, Aug 14, 2020 at 9:32 AM Stuart Hungerford
<stuart.hungerford@gmail.com> wrote:
>
> Hi,
>
> I'm using the technique described in this thread
> https://stackoverflow.com/questions/61179586/use-haskell-like-prelude-modules-in-a-module-in-raku
> to re-export module sub-trees in a project. One of these re-export
> modules also exports an infix operator. The others only export classes
> and roles.
>
> The operator-exporting module gives an error:
>
> Cannot import symbol '%?LANG' from 'Graphics::Shapes', because it
> already exists in this lexical scope.
>
> Can I modify the original technique to also cope with exported
> operators?  Is this still the best way to approach this issue?
>
> Thanks,
>
> Stu

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