I am going to sneak in a docs discussion into this ticket with regards to EXPORT some relevant parties are here.
http://docs.perl6.org/language/modules#EXPORT I mentioned when I wrote it: "Note, EXPORT can't be declared inside a package because presently rakudo (2015.09) seems to treat EXPORT as part of the compunit rather than the package." Of course, happy for that to change. With my more nuanced understanding of this I could re-write this as: "for EXPORT to be called it must be defined at UNIT::&EXPORT. Therefore it cannot be defined inside a package". Maybe if a package is declared as UNIT, all its lexical symbols could be inserted both into the package and UNIT. gfldex, I see you've edited the second EXPORT example, but to me it's made it much less clear what's going on. I see where you are going, trying to show that the power of ::T type captures can still be used in EXPORT, but I think we should leave that up to the imagination of the user. EXPORT is just a sub after all so those features are naturally there. Perhaps that example could go into a "cookbook" type thing. Thanks! On Tue, Jan 19, 2016 at 5:03 AM jn...@jnthn.net via RT < perl6-bugs-follo...@perl.org> wrote: > On Sun Jan 17 22:29:57 2016, gfldex wrote: > > # https://gist.github.com/b0d44595e0d3b314a09d > > > > # Module.pm6 > > unit module Module; > > > > sub EXPORT ($var) { > > { foo => sub () {} } > > } > > > > # use-module.p6 > > > > use v6; > > use lib '.'; > > use Module 42; > > > > # OUTPUT: > > # Error while importing from 'Module': > > # no EXPORT sub, but you provided positional argument in the 'use' > > statement > > # at /home/dex/projekte/perl6/rakudobug/EXPORT+unit-package/use- > > module.p6:3 > > # ------> use Module 42⏏; > > > > # Package.pm6 > > > > unit package Package; > > > > sub EXPORT ($var) { > > { foo => sub () {} } > > } > > > > # use-package.p6 > > > > use v6; > > use lib '.'; > > use Package 42; > > > > # OUTPUT: > > # Error while importing from 'Package': > > # no EXPORT sub, but you provided positional argument in the 'use' > > statement > > # at /home/dex/projekte/perl6/rakudobug/EXPORT+unit-package/use- > > package.p6:3 > > # ------> use Package 42⏏; > > > > # expected: either complain about unit and EXPORT in the same file or > > # make it work > > &EXPORT must be in the outermost lexical scope of the compilation unit. > Which...uh...it appears it should be here! I suspect the compiler is > sneaking a secret extra scope in as a result of the unit declaration. Can > we fix that? Yes for module/class/grammar. But for roles, not really as > they're generic and the parameter has to go somewhere. But that makes a > weird discontinuity. Hmmm. :-) > >