Background: There are a number of modules in the local lib eg Eg-1.rakumod Eg-2.rakumod Eg-3.rakumod, each Eg-\d is referenced in META6.json file, and each module has the code
sub SITE is export { ... }
Clarification: SITE is written in each example so the SITE.routes generates a CRO route set.
When another program eg., show-example.raku, is written with
use Eg-1;
my $routes = SITE.routes;
show-example.raku compiles and runs. SITE is in the namespace and yields a structure to be stored in $routes.
However, if we have in show-example2.raku
my @egs = <Eg-1 Eg-2 Eg-3>;
my $option = 1; # pointing to Eg-2
require ::(@egs[1]);
my $routes = SITE.routes
running raku -I. show-example2.raku fails to compile. Naturally because at compile time SITE is not known to be the name of a sub, although it will be known at runtime.
The question is how to refer to a sub that is known at runtime?
However, this does not seem to work:
my $routes = &::(@egs[1])::SITE.routes
error: No such symbol Eg-2::&SITE
require ::(@egs[1]) <&SITE>;? also your last attempt would work if&SITEis declaredour(it'smyby default)is exportis a part of) store any exported symbols (subs or any other) in aStash(Symboltable hash) namedDEFAULT(or other:tagifis export(:tag)is used) plus another calledALL. Symbols corresponding to theseStashes are in turn stored in anotherStashnamedEXPORT. And a symbol corresponding to that is stored in theStashcorresponding to the package whose symbols are being exported (in your code, the one::(@egs[1])refers to). Your presumption that it was otherwise is wrong but understandable.&::(@egs[1])::SITEyou would need to instead write&::(@egs[1])::EXPORT::DEFAULT::SITE. I'm currently planning to finish and post an answer that expands on the many topics I think worth covering.