Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my %exports;
- multi sub EXPORT(*@names) {
- my %imports;
- for @names -> $name {
- unless %exports{$name}:exists {
- die("Unknown name for export: '$name'");
- }
- %imports{ $name} := %exports{ $name}
- }
- return %imports;
- }
- unit module TestImports;
- sub bar is export { say "bar sub" }
- sub baz is export { say "baz sub" }
- my $var = 'He heu hey';
- my $aar = 'He heu hey';
- my $vaa = 'He heu hey';
- my $kar = 'He heu hey';
- my $vor = 'He heu hey';
- constant TOTITOTO = "patchamama";
- constant INTER = "jfklDJ";
- constant WANDER = "whoou";
- constant WANDER_FULL = "whoou";
- constant WANDER3FULL = "whoou";
- constant APPART is export(:AP) = 174;
- %exports = MY::.grep(*.key.match(/^ ( <[A..Z 3_]>+ ) $ /));
- #Use the line commended instead to export subs + constants.
- #%exports = MY::.grep(*.key.match(/^ ( <[A .. Z]>+ || <[&]> <[a .. z]>+ ) $ /));
- class Thing is export {
- method foo() {
- say "Inside foo method";
- }
- }
- #MAIN script: testImports.raku
- #!/bin/env raku
- use TestImports :DEFAULT , <TOTITOTO INTER WANDER>, :AP;
- #Everything works!
- say TOTITOTO;
- say INTER;
- say WANDER;
- bar();
- baz();
- Thing.new.foo;
- say APPART;
- #TODO: How to do the same with a TAG? so that some constants&|subs&|etc... behave like APPART constant.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement