I have been looking in Rakudo source for the implementation of require, first out of curiosity and second because I wanted to know if it was returning something.
I looked up sub require and it returned this hit, which actually seems to be the source for require, but it's called sub REQUIRE_IMPORT. It returns Nil and is declared as such, which pretty much answers my original question. But now my question is: Where's the mapping from that sub to require? Is it really the implementation for that function? Are there some other functions that are declared that way?
requireis not a sub, but rather a statement control (so, in the same category of things likeuse,if,for, etc.) It is parsed by the Perl 6 grammar and there are a few different cases that are accepted. It is compiled in the Perl 6 actions, which has quite a bit to handle.Much of the work is delegated to the various
CompUnitobjects, which are also involved withuse/need. It also has to take care of stubbing symbols that therequirewill bring in, since the set of symbols in a given lexical scope is fixed at compile time, and theREQUIRE_IMPORTutility sub is involved with the runtime symbol import too.The answer to your question as to what it will evaluate to comes at the end of the method:
Which means:
require Some::Modulethen evaluate to a lookup ofSome::Modulerequire $filestyle case, evaluate to the filename