Why doesn't temp work in Perl 6 kernel settings?

I was looking for this comment in an indir implementation:

 sub indir(Str() $path, $what, :$test = <r w>) { my $newCWD := $*CWD.chdir($path,:$test); $newCWD // $newCWD.throw; { my $*CWD = $newCWD; # temp doesn't work in core settings :-( $what(); } } 

I thought this use of my was weird, which led to doc issue 1082 when it was said that my actually lexical. I would think temp would be more suitable for user-level temporary changes for dynamic variables.

But now I see this comment, but I'm not quite sure what that means. Is this temp broken? Is it not available here? Or is the comment simply wrong?

If the comment is correct, it has this way of dealing with dynamic variables that have leaked to the ordinary level of programmers, because this is what some people have to do in the guts (and are they used to it?)

And how low is this level really? It seems that all Perl 6 should be available here.

+7
perl6 dynamic-scope lexical-scope
source share
2 answers

Perhaps a comment in the source code would be less erroneous if it were:

 # temp $*CWD doesn't work in core settings (which we're in) # my $*CWD = ... is a decent workaround in this case :) 

It seems that all Perl 6 should be available here.

Full Perl 6 should wait for the Perl 6 CORE parameter to compile. This corresponds to the Rakudo Perl 6 "core" src tree compiler . This includes code with "# temp not working in the main settings :-(" comment.

+5
source share

To emphasize the point of @raiph: in general, it is unreasonable to expect that any specific Perl 6 function implemented in rakudo will work anywhere in CORE, because this makes it possible to make these functions available.

Developers working on the kernel should be aware of this and take it into account, for example, in how to create CORE and what functions are available at this moment (and, in addition, which functions are more efficient at a lower level, so Perl 6, which you see in CORE, may not be idiomatic for several reasons.)

+2
source share

All Articles