Exportation Exploration
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 } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment