Created
October 26, 2018 03:50
-
-
Save FCO/18bbbbe640d7f8b83820fcb612ceec3d to your computer and use it in GitHub Desktop.
Exportation Exploration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Exportable; | |
sub bla is exportable { "bla" } | |
sub ble is exportable { "ble" } | |
sub bli is exportable { "bli" } | |
sub blo is exportable { "blo" } | |
sub blu is exportable { "blu" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multi exported-EXPORT() { | |
{} | |
} | |
multi exported-EXPORT(%funcs, Whatever --> Hash()) { | |
%funcs.kv.map: -> $k, &v { "&$k" => &v } | |
} | |
multi exported-EXPORT(%funcs, *@funcs --> Hash()) { | |
do for @funcs { | |
when Pair { | |
"&{.value}" => %funcs{ .key } | |
} | |
default { | |
"&$_" => %funcs{ $_ } | |
} | |
} | |
} | |
sub EXPORT { | |
my Routine %funcs; | |
multi trait_mod:<is>(Routine \r, Bool :$exportable! where * === True) is export { | |
trait_mod:<is>(r, :exportable(r.name)) | |
} | |
multi trait_mod:<is>(Routine \r, Str :$exportable!) is export { | |
%funcs{ $exportable } = r | |
} | |
{ | |
'&EXPORT' => sub (*@funcs) { exported-EXPORT %funcs, |@funcs } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use lib "."; | |
use Bla \[ "bla", ble => "blebleble" ]; | |
say bla; | |
say blebleble; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment