New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbols that start with core namespaces always get exported #1458
Comments
|
Note that this isn't anything to do with export really, it's about how symbol tables work. A declaration like What if we decided to do differently and insist that even if an outer |
|
So this is all By Design? Spamming all private symbols into the user's namespace the second the user uses some module we also happen to use is a serious flaw in the language IMO 😨 Somehow we managed to allow multiple authors to publish modules with the same name, yet using a namespace another module might be using causes a conflict. I was gonna release a module that provides Not to mention all $ cat Foo.pm6
my subset Foo is export where *;
$ cat Foo/Two.pm6
use Foo;
my subset Foo::Two where *;
$ perl6 -I. -MFoo::Two -e 'say 42 ~~ Foo::Two'
Could not find symbol '&Two'
in block <unit> at -e line 1
$ perl6 -I. -MFoo -MFoo::Two -e 'say 42 ~~ Foo::Two'
True |
|
On 31 Jan 2018, at 11:16, Jonathan Worthington ***@***.***> wrote:
With IO however, it finds the existing package in CORE and installs it under that.
What if we decided to do differently and insist that even if an outer Foo exists, we will simply install a fresh my package Foo {} into the current lexical scope? In that case, we'd end up hiding the Foo from the outer scope (or, in your specific example, hiding the CORE IO package and forcing everyone to write CORE::IO::Path afterwards).
But that would only be applicable in the *lexical* scope where this new IO is installed, no? Still not ideal, but not as “global” as you appear you claim it to be?
|
Rather, isn't it just that you're reopening [11:56] <Ven``> m: my package UserPkg {}; BEGIN with '/tmp/subz'.IO.mkdir { .add('ZS.pm6').spurt: 「package UserPkg {}; my subset UserPkg::Foo is export(:e) where 42」 }; use lib </tmp/subz/>; use ZS; say 42 ~~ UserPkg::Foo
[11:56] <camelia> rakudo-moar ed9b287c9: OUTPUT: «True» |
|
IIRC, this also affects multi sub is exported by default even only one of them is marked as |
|
On Mittwoch, 31. Jänner 2018 11:16:48 CET Jonathan Worthington wrote:
What if we decided to do differently and insist that even if an outer `Foo`
exists, we will simply install a fresh `my package Foo {}` into the current
lexical scope? In that case, we'd end up hiding the `Foo` from the outer
scope (or, in your specific example, hiding the CORE `IO` package and
forcing everyone to write `CORE::IO::Path` afterwards).
There's a third option: install a fresh package Foo lexically but give it a
reference to the outer Foo for fallback symbol lookup. Kinda like the already
existing global_fallback in Stash's AT-KEY.
|
Yes.
I never claimed it was global, just that it'd be a decided impact. |
Yes, except there's no explicit re-opening because stashes are always open to poke symbols in to. |
I've pondered that before, and we could indeed do that, yes. It would complicate lookup some, but since most of those take place at compile time, it's not a big issue. |
Well, The Design was more a wish list of things that should work, and what's implemented today is the best realization of it that we have so far. There's certainly room for refinement. In general, there's long been a tension between |
This one, thankfully, should be a separate, and much more easily resolved, issue. |
If I name my subset
IO::Path::Foo, theexporttag is basically ignored and the subset always gets exported:It works as expected for paths that don't match anything core:
The text was updated successfully, but these errors were encountered: