Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 A = 333;
- constant TOTITOTO = "patchamama";
- constant INTER = "jfklDJ";
- constant WANDER = "whoou";
- constant WANDER_FULL = "whoou";
- constant WANDER3FULL = "whoou";
- constant COLOR_A = 24;
- constant COLOR_B = 80;
- constant COLOR_C = 80;
- constant COLOR_D = 80;
- constant APPART is export(:AP) = 174;
- constant COLOR_E is export(:SPECIAL)= 80;
- constant COLOR_F = 80;
- constant COLOR_G = 80;
- constant COLOR_H = 80;
- constant COLOR_I = 80;
- my package EXPORT::MYTAG {
- my %excluded = EXPORT::.grep( *.key.grep( none /^ : ( ALL || DEFAULT || MYTAG ) $ /));
- say '%excluded : ' ~ %excluded.raku;
- my %all_in_tag_AP := EXPORT::AP::;
- say '%all_in_tag_AP => ' ~ %all_in_tag_AP.raku;
- #
- for %excluded.kv -> $k,$v {
- say $k ~ ' => ' ~ $v.raku;
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! HERE COMES THE QUESTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #How to interpolate in order to get yet exported symbols, tried:
- #my %key_value_sym = ::GLOBAL::EXPORT::($k)::; # Fails! but WHY.
- }
- my %to_put_into_MYTAG = TestImports::.grep(*.key.match(/^ ( <[A..Z 3_]>+ ) $ /));
- for %to_put_into_MYTAG {
- next if .key eq 'EXPORT'; #Must avoid EXPORT key
- next if .key eq 'APPART'; #Must avoid yet exported tagged APPART
- next if .key eq 'COLOR_E'; #Must avoid yet exported tagged COLOR_E
- OUR::{.key} := .value;
- }
- #but the problem is `APPART` AND `COLOR_E` should be genericly avoided
- #beeing collected by the precedent loop.
- }
- class Thing is export {
- method foo() {
- say "Inside foo method";
- say "CONSTANT A is : " ~ A;
- #say "MYCONSTANT : " ~ EXPORT::colors::MYCONSTANT;
- }
- }
- #Now here is Main script testimport.raku
- #!/bin/env raku
- #use TestImports :DEFAULT , <TOTITOTO INTER WANDER>, :AP :colors;
- #use TestImports <MTAG> ;
- use TestImports :DEFAULT, :MYTAG ,:AP, :SPECIAL ;
- #Everything works!
- say TOTITOTO;
- say INTER;
- say WANDER;
- say WANDER_FULL;
- say WANDER3FULL;
- say APPART;
- say TestImports::A;
- say COLOR_E;
- say COLOR_F;
- #say COLOR_INTER;
- bar();
- baz();
- Thing.new.foo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement