Skip to content

Instantly share code, notes, and snippets.

@0racle
Forked from FCO/Bla.pm6
Created October 26, 2018 04:18
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/4e7eda5ad877c91e74381089d6119562 to your computer and use it in GitHub Desktop.
Save 0racle/4e7eda5ad877c91e74381089d6119562 to your computer and use it in GitHub Desktop.
Exportation Exploration
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" }
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 }
}
}
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