Skip to content

Instantly share code, notes, and snippets.

@0racle
Last active March 29, 2018 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0racle/a8121cfbb8ba920dca3670d47ca1861a to your computer and use it in GitHub Desktop.
Save 0racle/a8121cfbb8ba920dca3670d47ca1861a to your computer and use it in GitHub Desktop.
Sub-Module Function Exports

Sub-Modules

  • lib/Foo/Bar.pm6
unit module Foo::Bar;

sub bar(|) is export { 'bar' }
  • lib/Foo/Baz.pm6
unit module Foo::Baz;

sub baz(|) is export { 'baz' }

Module

  • lib/Foo.pm6
unit module Foo;

use Foo::Bar;
use Foo::Baz;

my package EXPORT::bar { OUR::< &bar > := &bar }
my package EXPORT::baz { OUR::< &baz > := &baz }
my package EXPORT::ALL {
    OUR::< &bar > := &bar;
    OUR::< &baz > := &baz;
}

sub foo(|) is export(:foo :ALL) { 'foo' }

App

  • app.p6
use lib 'lib';
use Foo :foo, :baz;

say foo();
#say bar(); Can't use, not imported
say baz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment