You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several special variables like %*ENV, $*PID, %*SIG, $*PROGRAM_NAME which from the outside of a UNIX process affect the whole program, but inside of Perl 6 they are scoped dynamically.
So, what happens when such a dynamic variable is redefined? Does the new variable loose its special association with the process?
Consider
my @list := gather loop {
take my $*PROGRAM_NAME = 'a'..'z'.roll(5)
}
.say for @list;
(in Perl 5, $0 is assignable and changes the program name as reported by ps aux, and I expect the same to be true for Perl 6).
Does the program name change every single time @list is being reified?
If yes, how could that be implemented in an efficient manner that doesn't affect all control flow?
If not, what's the point of having those variables dynamically scoped?
The text was updated successfully, but these errors were encountered:
What I seem to recall from past conversations with @TimToady is that once upon a time, there were two forms - $*VAR for global variables and $+VAR for dynamically scoped variables, or maybe the other way around. Then somebody noticed that global scope was just a special case of dynamic scope, and the two concepts were merged.
My opinion here is that my $*PROGRAM_NAME is probably wrong, and if you want to change the reported program name, it would be better to use temp $*PROGRAM_NAME = .... Maybe it would make sense to reintroduce a distinction between names that it makes sense to override with my, and names that don't.
There is already a name distinction; you may use PROCESS:: to refer to the process-wide variant. The dynamic variants are useful for programs that want to lie to themselves in a dynamic scope.
There are several special variables like
%*ENV
,$*PID
,%*SIG
,$*PROGRAM_NAME
which from the outside of a UNIX process affect the whole program, but inside of Perl 6 they are scoped dynamically.So, what happens when such a dynamic variable is redefined? Does the new variable loose its special association with the process?
Consider
(in Perl 5, $0 is assignable and changes the program name as reported by
ps aux
, and I expect the same to be true for Perl 6).Does the program name change every single time
@list
is being reified?If yes, how could that be implemented in an efficient manner that doesn't affect all control flow?
If not, what's the point of having those variables dynamically scoped?
The text was updated successfully, but these errors were encountered: