Skip to content

Commit

Permalink
Reconsider %REQUIRE_SYMBOLS
Browse files Browse the repository at this point in the history
First, change the name to `%?REQUIRE-SYMBOLS`. This makes sense for
reducing the chances of conflicting with user's code lexical. Also,
since this is a true compile-time symbol it deserves the `?` twigil.

Second, make it a `Stash`. For now this mostly makes sense
ideologically, as it is a symbol container in first place. But also,
since some steps were already made to reduce chances of races in `Stash`
code, this helps in making multi-threaded code more robust.
  • Loading branch information
vrurg committed May 13, 2022
1 parent 0293ae5 commit ad2fdca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/Perl6/Actions.nqp
Expand Up @@ -2300,9 +2300,10 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $lexpad := $world.cur_lexpad();
my $block := $lexpad.ann('code_object');
$block := $world.blocks[+$world.blocks - 2] if $block.HOW.name($block) eq 'Code';
if !$lexpad.symbol('%REQUIRE_SYMBOLS') {
declare_variable($/, $past, '%', '', 'REQUIRE_SYMBOLS', []);
$world.mark_lexical_used_implicitly($lexpad, '%REQUIRE_SYMBOLS');
if !$lexpad.symbol('%?REQUIRE-SYMBOLS') {
my $Stash := $world.find_single_symbol_in_setting('Stash');
$world.install_lexical_symbol($lexpad, '%?REQUIRE-SYMBOLS', $Stash.new, :clone);
$world.mark_lexical_used_implicitly($lexpad, '%?REQUIRE-SYMBOLS');
}
my $require_past := WANTED(QAST::Op.new(:node($/), :op<call>,
:name<&REQUIRE_IMPORT>,
Expand Down
8 changes: 4 additions & 4 deletions src/core.c/operators.pm6
Expand Up @@ -244,8 +244,8 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is raw is implementation-detail {
)
}

my Mu $thing := $root.EXISTS-KEY('%REQUIRE_SYMBOLS')
&& (my $REQUIRE_SYMBOLS := $root.AT-KEY('%REQUIRE_SYMBOLS'))
my Mu $thing := $root.EXISTS-KEY('%?REQUIRE-SYMBOLS')
&& (my $REQUIRE_SYMBOLS := $root.AT-KEY('%?REQUIRE-SYMBOLS'))
&& $REQUIRE_SYMBOLS.EXISTS-KEY($first)
?? $REQUIRE_SYMBOLS.AT-KEY($first)
!! $root.EXISTS-KEY($first)
Expand Down Expand Up @@ -280,7 +280,7 @@ sub REQUIRE_IMPORT(
my $DEFAULT := $handle.export-package()<DEFAULT>.WHO;
my $GLOBALish := $handle.globalish-package;
my @missing;
my $block := CALLER::.EXISTS-KEY('%REQUIRE_SYMBOLS')
my $block := CALLER::.EXISTS-KEY('%?REQUIRE-SYMBOLS')
?? CALLER::MY::
!! CALLER::OUTER::;
my $merge-globals-target := $block;
Expand Down Expand Up @@ -330,7 +330,7 @@ sub REQUIRE_IMPORT(
) if $stubname;
# Merge GLOBAL from compunit.
nqp::gethllsym('Raku','ModuleLoader').merge_globals(
$block<%REQUIRE_SYMBOLS>,
$block<%?REQUIRE-SYMBOLS>,
$GLOBALish,
);
}
Expand Down

0 comments on commit ad2fdca

Please sign in to comment.